I have a folder which includes several files named
[ID] is a string e.g.
orderID1.log orderID2.log orderID3.log orderID4.log ...
I need to write a script in Linux to
grep each file by the
ID in their name and output the result to a file named
orderID1.log, I need to
grep 'ID1' orderID1.log > ID1.log
orderID2.log, I need to
grep 'ID2' orderID2.log > ID2.log
I tried to write the script below,
for i in ORDER*.log do grep 'i' order$i > $i.log; done
The problem here is that i will be record as "orderID1","orderID2" rather than "ID1","ID2". Is there a simple way to do this in linux ?