outputs:
Aia's script find . -name '*.txt' -type f -print0 | xargs -0 perl -nle '/0.01/ and print $ARGV and close ARGV'
outputs:
And Don's script
find . -name '*.9tmp' -exec grep -Fl 0.1 {} +
Outputs:
So, my modified script and Don's output the expected/desired result. Why is that my first script and Aia's do not produce the same result?
Expanding a little on what I said in post #7, grep 0.1 and grep -E 0.1 use basic regular expression and extended regular expression matching, respectively, and in both cases the <period> in 0.1 matches any character. So, the RE 0.1 matches the text in red in the output:
but I have absolutely no explanation for why your first script:
did not also find:
nor why id didn't report many of the files found by Aia's perl script.
My suggestion worked because grep -F 0.1 performs a fixed string search; not a regular expression search, and in a fixed string search the <period> in 0.1 only matches a <period>.
And, using grep -l just prints the name of a file that contains a match (without displaying the matching text) and moves on to the next file instead of looking for all possible matches in a single file.
This User Gave Thanks to Don Cragun For This Post:
Expanding a little on what I said in post #7, grep 0.1 and grep -E 0.1 use basic regular expression and extended regular expression matching, respectively, and in both cases the <period> in 0.1 matches any character. So, the RE 0.1 matches the text in red in the output:
Got it!
Quote:
but I have absolutely no explanation for why your first script:did not also find
Quote:
nor why id didn't report many of the files found by Aia's perl script.
Sorry, I just listed a small subset. I was not very clear in my following statement outputs (subset):
Hello Everyone ,
Iam a newbie to shell programming and iam reaching out if anyone can help in this :-
I have two files
1) Insert.txt
2) partition_list.txt
insert.txt looks like this :-
insert into emp1 partition (partition_name)
(a1,
b2,
c4,
s6,
d8)
select
a1,
b2,
c4, (2 Replies)
Hi everyone,
Is it possible to have the command strings exclude particular files?
Here is what I am currently writing:
strings *20161212*
It prints all files in the directory, which is good, but some file types do not need to be printed because they contain gibberish. I am trying the... (5 Replies)
Hi team,
I'm a newbie of Perl Script and looking to create a simple perl script that will run in the Linux system:
1) to find process, such as ps -ef | grep process name
2) to exclude strings from the output if it found, for instance if i see abc from usr process, then will exclude it from... (1 Reply)
I have a file 1.txt with the below contents.
-----cat 1.txt-----
1234
5678
1256
1234
1247
-------------------
I have 3 more files in a folder
-----ls -lrt-------
A1.txt
A2.txt
A3.txt
-------------------
The contents of those three files are similar format with different data values... (8 Replies)
Hello Team,
There is this situation where there are around 20 *.gz files and i want to search multiple words from all those files.
Example as below :
filea.gz
fileb.gz
filec.gz
now i want to search words "hi" and "hello" from all these 3 files without... (4 Replies)
Been searching for about 3 hours for similar functionality that I can get examples of how to output text from variables into certain locations in a file. I would like to incorporate this into a script. I have not been able to find a command example that does it all in one method. I find part of... (1 Reply)
Hi all,
I'd like you to help or give any advise about the following:
I have two (2) files, file1 and file2, both files have information common to each other. The contents of file1 is a subset of the contents of file2:
file1:
errormsgadmin
esdp
esgservices
esignipa
iprice
ipvpn
irm... (0 Replies)
I am trying to find socail security numbers in files in (and under) a specific directory and output a list of the files where they are found... the format would be with no dashes just 9 numeric characters in a row.
I have tried this:
find /DirToLookIn -exec grep '\{9\}' /dev/null {} \; >>... (1 Reply)
experts,
i am using solaris 9. there are serveral *.log files in a directory "/var/alllogs/". Among the files one or several files contain the string "0198634873".
I want do-
cat *.log | grep "0198634873"; And want to see which Files(file_name) contain that string. Plus output will go to a... (3 Replies)