-   Programming (
-   -   sed - Search and Replace /phrase (

Darrell22 03-03-2013 12:30 PM

sed - Search and Replace /phrase
Dear Experts,

I have two files with the output of directory structures:



home_files.txt contains rows such as:

backupfat32_files.txt will have an added string on the front:


How can I use sed to remove


I tried this, but it's not quite:

cat backupfat32_files.txt | sed 's/backupfat32//g'



It's an escape character that I need, correct?

Unfortunately, I can't find a webpage with a clear and simple example that works.

Thanks a lot!

Snark1994 03-03-2013 12:50 PM


cat backupfat32_files.txt | sed 's/\/backupfat32//g'
is what you want, or


cat backupfat32_files.txt | sed 's@/backupfat32@@g'
(your delimiter character need not be '/'), or


sed 's@/backupfat32@@g' backupfat32_files.txt
(eliminating the useless use of cat)


Snark1994 03-03-2013 12:50 PM

-- forum double-posted my above response --

Darrell22 03-04-2013 10:35 AM

That worked!

I was using cat, so that I wouldn't mess up the file, and it echos to screen.

You answered in only 20 minutes! Cool.

Thanks a lot! I really appreciate it.

Snark1994 03-05-2013 01:50 PM

No problem :) please mark the thread as 'SOLVED' using the link at the top of the page.

All times are GMT -5. The time now is 08:50 AM.