Originally Posted by BostonMACOSX
I have a simple shell script that loops through a text file.
There is one value on each line I use to delete a specific folder.
The part I'm missing how to do it remove that line from the text file.
So basically....loop through the text file and remove the line after using it to be a variable of a command.
Something like this should do:
Code:
while read cur_line
do
folder=`echo $cur_line | awk '{print $2}'`
echo Currently deleting $folder...
sed "/$cur_line/d" yourfile> tempfile
mv tempfile yourfile
done < yourfile
I don't know what you're using to find the folder-to-be-deleted's name on the current line, but I set it up to be the second field in the current line using that
awk statement in the while loop. If you need help, just post again and I'll clarify...
Basically, use
sed to delete the line from the file, then output it to a temp file, then move that temp file back to the name of your file.