I'm writing a script that selects rows from files in a directory which contain patterns $f1, $f2 and $f3 and storing the lines that contain the pattern in a file I want to call as $file_$pattern.xls
, for example file1_2.54 Ghz.xls
.
#!/bin/bash
#my_script.sh to summarize p-state values
f1="2.54 Ghz"
f2="1.60 Ghz"
f3="800 Mhz"
for f in $f1 $f2 $f3
do
for file in *.txt
do
grep $f1 $file > ${file}_${f1}.xls
done
done
Kindly help me with the script.