Reputation: 25
This is the continuation of my previous question. deleting lines from text files based on the last character which are in another file using awk or sed
I am trying to get the following output using my previous example? I am new to awk.Please give suggestions.
csh 1 A 1 27.704 6.347
csh 2 A 1 28.832 5.553
csh 3 A 1 28.324 4.589
csh 6 A 1 28.378 4.899
Upvotes: 2
Views: 312
Reputation: 786339
Taking some code from previous answers, you can use this code:
while read word; do
if [[ $word =~ ^(....)(.)$ ]]; then
filename="yy/${BASH_REMATCH[1]}.txt"
letter=${BASH_REMATCH[2]}
[[ -f $filename ]] && sed -i.bak -n "/^ *csh.*$letter/p" $filename
fi
done < xx.txt
Upvotes: 1
Reputation: 360703
You need to carry forward any information from the previous question that provides specifications for this one.
This may work for you:
awk '$3 == "A"' inputfile
You can replace "inputfile" with a glob, perhaps *
, in order to process multiple files as if they were cat
ed together.
Without having a clearer indication of how you want the multiple files processed, that's the best I can do.
Upvotes: 1