if I have text like
/mnt/data/web/web content/page 1/home page.txt
I get my text with the following command that is then piped to another command.
cat somefile.txt | awk '{$1=$2=$3=$4=$5=$6=$7=$8=$9=$10=""; print $0}'
I need to pipe the above command into another command to add the back slashes
How can I add a back slash before every space so I get correct *nix paths
ie.
/mnt/data/web/web\ content/page\ 1/home\ page.txt
the text could theoretically be infinitely long but I always need a backslash before every space. Final script is to be used in freebsd & linux
thanks!
This awk
should do:
awk '{gsub(/ /,"\\ ")}8' file
/mnt/data/web/web\ content/page\ 1/home\ page.txt
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With