I'm trying to remove the first / from a string in a shell script.
For example
file:///path/to/file
and output to
file://path/to/file
If the string is in a shell variable, then you can use shell parameter expansion:
$ var='file:///path/to/file'
$ echo "${var/\//}"
file://path/to/file
Something like will do the work:
A="file:///path/to/file"
B=$(echo $A|sed 's@/@@')
without g at the end in sed the program will change only first occurrence
I Tried with below method and it worked fine
@praveen_linux_example ~]# echo "file:///path/to/file" | sed "s/\///1"
file://path/to/file
Command: echo "file:///path/to/file" | sed "s/\///1"
Output
file://path/to/file