Reputation: 1403
I have a below input file(input.txt
). I want to remove the given extension(ec.txt) in input.txt
Content of input.txt
abcd.html
apple
browser.do
image.gif
net.asp
and I have an extension check file (ec.txt
)
Content of ec.txt
.html
.gif
.do
I want to remove the extensions from input.txt
, for the extensions available in the ec.txt
file
Content of output.txt
abcd
apple
browser
image
net.asp
Upvotes: 0
Views: 41
Reputation: 195209
this awk one-liner will do the job:
awk -F. -v OFS="." 'NR==FNR{a[$2];next}$NF in a{NF--}7' ec.txt input.txt
Upvotes: 2