I have a question on bash. Basically I would like to print a file name using bash. I am actually trying to grep a particular character in sequential files.
I have alot files such that a.txt, b.txt,c.txt...etc.
If I found a certain character, I would print that particular filename.
I used something like
cat *.txt|grep -w 56|awk '{
if($1 -eq "bla1")
then
print the filename (e.g a.txt)
Currently, I try to print some simple echo inside but i could not see any output.
Initially, I think of using this command too. But, the motivation is to find the match of number in these files and extract the first field. If the first field is the "search string" it would print the filename.
In other words, I have to get two information. For example:-
Input file (a.txt) has:-
@@@ 10 testingtestingtestingtesting
Initially, i need to grep the 10 in any *.txt and then get the first field. If first field is @@@@, i would print the filename.
If using the above command, I could only get the filename when I need to match only one type of information.