Linux – sed replace slash

linuxsed

am using

!/bin/bash
     for fl in *.txt; do
     mv $fl $fl.old
     sed 's/files.php?file=/file/g' $fl.old > $fl
     rm -f $fl.old
     done

I need the output replaced with file/ not only file ,
couldnt figure it out

Best Answer

Use:

sed 's/files.php?file=/file\//g;' $fl.old > $fl

Notice the \ used to escape the / after file in the replacement ...

Related Topic