Reputation: 35
I have 10 files in a folder. All with similar pattern with text and number:
ABCDEF20141010_12345.txt
ABCDEF20141010_23456.txt
ABCDEF20141010_34567.txt
...
I need to process these files in a loop.
for filename in `ls -1 | egrep "ABCDEF[0-9]+\_[0-9]+.txt"`
do
<code>
done
Above egrep
code, is not going inside the loop. Can you please help me in modifying this search?
Upvotes: 2
Views: 42
Reputation: 9312
You don't have to use ls
and grep
. It's working with shell-only functionalities:
for filename in ABCDEF[0-9]*_[0-9]*.txt
do
echo $filename
#do whatever
done
Upvotes: 1