I have file A with 10 lines and file B with 15 lines
I have to read each line from file A and match it with lines in file B
If matching lines are found i need to delete it from file B
The ouput will be the deleted file B
I tried the following in the loop but the deleting part is not working
while read fileA
do
sed -e "/$fileA/d" fileB > new deleted file
OR
cat grep -Ev '$fileA' fileB > new deleted file
done
The problem here is i need to put the "new deleted file" as input in my sed or grep command...or how to do it recursively
yongitz
2
A simple
grep -vf fileA fileB
might do the job. You don't need the while statement I guess.
This is somehow not fulfilling my requirement
Since i am deriving the matching pattern from file A i need a loop
Thanks
yongitz
4
You might want to post here your sample input files and your expected output file.
file A is like this
/path1/source/web/service,25,RRR,1.0
/path2/source/web/service,25,RRR,1.0
/path3/source/web/service,25,RRR,1.0
/path4/source/web/service,25,RRR,1.0
file B is like this
/path1/source/web/service 2.0
/path2/source/web/service 3.0
/path3/source/web/service 4.0
/path4/source/web/service 3.0
/path5/source/web/service 4.4
i am matching with the first column in file A to file B
eg /path1/source/web/service.....
so that my output is
/path5/source/web/service which doent match....
yongitz
6
What I have in mind is a nasty solution..
- extract the 1st columns from both files using cut or awk the redirect the output to a temp file.
- use the suggested grep command above.
yongitz@wolfgang:/tmp$ cat a.txt
/path1/source/web/service,25,RRR,1.0
/path2/source/web/service,25,RRR,1.0
/path3/source/web/service,25,RRR,1.0
/path4/source/web/service,25,RRR,1.0
yongitz@wolfgang:/tmp$ cat b.txt
/path1/source/web/service 2.0
/path2/source/web/service 3.0
/path3/source/web/service 4.0
/path4/source/web/service 3.0
/path5/source/web/service 4.4
yongitz@wolfgang:/tmp$ cut -d, -f1 a.txt > x.txt
yongitz@wolfgang:/tmp$ cut -d" " -f1 b.txt > y.txt
yongitz@wolfgang:/tmp$ grep -vf x.txt y.txt
/path5/source/web/service
This is a nasty solution and I guess awk can compare certain columns of two files.