I have a set of list that contains file names. I want to search through each of the list and delete any file that is found in the list.
eg.
LIST_A contains:
aaa
bbb
ccc
ddd
eeee
LIST_B contains:
aab
aac
adb
aed
assuming I want to delete 'aac' from the list and I don't know which of the list contains 'aac', what's the best way to search through the list and delete the file if found?
This is what i've tried
ans=`cat LIST_A | grep aac`
if [[ $ans = "" ]]
then
echo "Not found in LIST_A"
ans2=`cat LIST_B | grep aac`
if [[ $ans2 = ""]]
then
echo "Not founf in LIST_B"
else
** delete the line (How will I code this portion)**
fi
else
** delete the line (How will I code this portion)**
fi
I will appreciate whatever assistance I can get from you guys.
Actually what I wanted it to remove the entire line where the string is found. So it's like deleting the whole line. I'll give both suggested solution a trial.