user3437235 user3437235 - 4 months ago 39
Linux Question

Sed appears to be deleting the full line

Hi guys I'm trying to use sed to delete part of a string (its a directory). I'm using it like so

sed -i 's/$1//g' ~/Desktop/RecyclingBin/logs/$1

whenever I open the text file it appears to be blank. Any help would be appreciated..

Also if there's an easier way to output a files location to a text file without the actual filename being in the output that would make life a lot easier currently using:

find $PWD -type d -name "*$1*" >> ~/Desktop/RecyclingBin/logs/$1

thank you in advance!


You can do this in find itself:

find . -type d -name "*$1*" -exec bash -c 'echo "${1##*/}"' - {} \;