Previous topic - https://stackoverflow.com/questions/40808975/overwrite-script-in-bash-shell
I'm working on a university project where we have to create a recycling bin with a del and restore option. I have completed both of these parts and the restore option works (mostly). It saved the location of the deleted file in a txt file called FilePaths to be used as reference when restoring the file back to it's original location.
I know that when duplicates of a file location are saved into this file it causes problems so I have to create a line in a bash script that deletes the specific file location string from the text file.
I know sed can help and I can manipulate it to do whatever i want it to however the problem is it doesn't seem to do anything at all. I've even tested it using a simple "test2" text file with the word hello inside.
sed '/hello/d' test2
this does absolutely nothing. I've tried it with double quotes and still absolutely nothing, it doesn't remove "hello" from my test2 file at all
In terms of the restore function, this is what I have so far
#!/bin/sh
#navigate to the Recycle_Bin directory
cd $HOME/Recycle_Bin
#take the string from FilePaths and save it to restore
restore="$(grep "$1" "$HOME/FilePaths")"
#take the string saved in restore and use it as the file's path
filename="$(basename "$restore")"
#remove the string matching restore within FilePaths
sed '/$restore/d' $Home/FilePaths
#set location
location="$(readlink -f "$location")"
#move file to original location
mv -i "$1" "$(grep "$1" "$HOME/FilePaths")"
Can anyone think of any reason why sed won't work? I've been searching for hours and can't find any answer, I could use awk but I feel sed would make my code simpler