Awk to replace directory paths

Hi all,

I have written a bash script to do a few things for my Splunk deployment, however, I am currently stuck on one part...

I need to the current working directory (I collect this with `pwd`) in the script as it could in theory be run from a number of locations. I'm not that great with awk and haven't used it in a while. Below is the lines i'm trying to convert to/from:
FROM:

/var/tmp/scripts/testbed/tcpdump/bin

TO:

\\/var\\/tmp\\/scripts\\/testbed\\/tcpdump\\/bin

I need to add the "\\" to the path as i'm using echo -e to write to another file so one "\" will be escaped. and then I need the other to be there in the file (as it's part of a regex) I hope this makes sense.

Thanks in advance,

Matt

sed 's;/;\\\\/;g'
echo '/var/tmp/scripts/testbed/tcpdump/bin' | sed 's#/#\\\\&#g

Thanks guys that did the trick, now my regex just needs fixing....
I've not used sed before, i know it replaces text just unsure of the syntax

If you explain in detail what you're actually trying to accomplish, I bet there's a simpler and more direct way than this.

If you really want to use awk:

awk -F/ '{OFS="\\\\/"; $1=$1; print}'