is it possible to use input from a txt file as a variable in a shell script, basically what I want to do is take the information form a txt file (in this case a list of directory and files) and have a loop go through line by line and delete the files within the txt file;
exmp;
txt-file
/home/username/txt.1
/home/username2/txt.1
/home/username2/txt.2
what I would like to do is have it delete these files. My inital example script is ;
Code:
#!/bin/bash
echo "Enter String To Search For"
read string
echo "Enter directory to search in"
read dir
echo " Scanning $dir for $string"
grep -Hr $string $dir | cut -d: -f1 >> infected
cat infected | more
echo "Shall i delete these files"
read ans
if [ $ans = y] then;
[command]
fi
if [ $ans = n] then;
[command]
fi
which is made to take the String from a iframe injection/javascript injection grep the files for it and output the grep data to a file called "injected" I would like to then take the input from the "infected" file to gradually delete the files listed in the txt file. Problem is I can only find a way to make it look on a pure hard coded option within the script
Code:
for name in tim dick harry
do
echo "$name
done
I am looking to be able to take the for name option and use it for the main script, but pull the data from the txt file "infected" any one have any ideas?