First, you can use another character as the s///
delimiter. The command
sed 's:ABC:DEF:g'
is equivalent for
sed 's/ABC/DEF/g'
It will make your command more readable because you'll not have to escape the slash.
Said that, some seds do not support character escaping such as \t
. It happens to me a lot in Mac OS X, for example. My solution is to press Control+V and then the tab char:
sed 's:/:<Control+V><TAB character>:g'
The result in my machine is:
$ pwd
/Users/brandizzi/sandbox/demo/mydemo
$ pwd | sed 's:/: :g'
Users brandizzi sandbox demo mydemo
However, if your intention is to put all path directories in awk variables $1
, $2
etc. just declare the slash to be the field separator with awk -F
flag:
$ pwd
/Users/brandizzi/sandbox/demo/mydemo
$ pwd | awk -F / '{print $3 " " $5}'
brandizzi demo