Hi
I have 2 directories t1 and t2 with some files in it. I have to see whether the files present in t1 is also there in t2 or not. Currently, both the directories contain the same files as shown below:
$ABC.TXT
def.txt
Now, when I run the below script, it tells def.txt is found, $ABC.TXT not found. Since the filename itself contains wildcard, grep seems to be having some issue:
Output:
Please advice. I have put 2 files for samples. I also have some files like $$ABC.TXT, $$$ABC.TXT.
Hi Jerry
Thanks for your reply. The number of files I have in the source and destination directories are around 50k, and hence using a nested for will cause some performance issue.
...
The number of files I have in the source and destination directories are around 50k, and hence using a nested for will cause some performance issue.
...
Have you tested or benchmarked this claim?
The "grep" method essentially does a nested loop as well. It's just more concise and a more "Perlish" way of doing things.
With a setup consisting of two directories "t1" and "t2" having 10,005 identical files, my benchmark shows this -
This shows that -
(A) Perl's "grep" operator takes 148 seconds on an average to compare 10,005 files in directories "t1" and "t2".
(B) Perl's nested loop method takes 7.27 seconds on an average to compare 10,005 files in directories "t1" and "t2".
tyler_durden
---------- Post updated 02-10-11 at 01:44 PM ---------- Previous update was 02-09-11 at 02:15 PM ----------
Quote:
Originally Posted by guruprasadpr
...it tells def.txt is found, $ABC.TXT not found. Since the filename itself contains wildcard, grep seems to be having some issue:
...I also have some files like $$ABC.TXT, $$$ABC.TXT.
...
For academic interest, if you were looking for a solution for the problem mentioned in your original post, you will have to quote the string you are searching for, so that it isn't interpolated -
job_count=`grep -e "The job called .* has finished | The job called .* is running" logfile.txt | wc -l`
Any idea how to count those 2 patterns so i have a total count of the finished and running jobs from the log file?
If i do either of the patterns its works okay but adding them together... (8 Replies)
Platforms : Solaris 10 and RHEL 5.6
I always get double quotes , single quotes and asteriks mixed up for find, ls and grep commands.
The below commands retrieve the correct results. But , unders stress , I get all these mixed up :mad: .So, i wanted to get a clear picture.
Please check if... (7 Replies)
Hi all
I want to search for number in file presented with wildcard as shown below.
cat file.txt
1405
1623
1415
.......
.......
How to search for the number 141526 for example?
If the number exist print "Number 141526 exist" if no, print "The number not exist"
Thank you in advance. (3 Replies)
Im storing multiple functions in a varaible called $check...
The variable check contains the following:
a()
b()
c()
...
..etc
now im checking individually which function is kept in which file using GREP
if ( grep \$check \i, <FILE> )
The problem is im getting the output for the... (1 Reply)
Hello,
I'm looking for a search string within about 50 files but when the string is found it doesn't tell me in which member it has been found. Any ideas how I can do this?
Cheers
Rob (4 Replies)
I have a question regarding Perl scripting.
If I want to say open files that all look like this and assign them to a filehandle and then assign the filehandle to a variable, how do I do this?
The file names are
strand1.fa.gz.tmp
strand2.fa.gz.tmp
strand3.fa.gz.tmp
strand4.fa.gz.tmp
...... (6 Replies)
Good evening All,
I have a perl script to pull out all occurrences of a files beginning with xx and ending in .p. I will then loop through all 1K files in a directory. I can grep for xx*.p files but it gives me the entire line. I wish to output to a single colum with only the hits found. ... (3 Replies)
Hi there,
is it possible to use wild cards in this statement
ssh $remote_server 'perl -pi -e "s,EXP_SERIAL_19b8be67=\"\",EXP_SERIAL_`hostid`=\"UNKNOWN\"," /var/myfile'
This command works fine but the bit in bold (the 8 character hostid) will not always be 19b8be67 so I was hoping I could... (2 Replies)
hello,
we have a script (let say ABC) which contains the below:
lp -d lp06 -t 'REPORT FOR FINANCE -FIN-' $daily/FINRPT
lp -d lp06 -t 'REPORT FOR FINANCE -FIN1-' $daily/FINRPT1
lp -d lp06 -t 'REPORT FOR HUMAN RESOURCE -HR-' $dd_daily/HRRPT
lp -d lp06 -t 'REPORT FOR MANAGEMENT -MGM-'... (10 Replies)
Hi guys,
a small problem today, I'm grepping a log file containing lines like this below:
Mar 09 16:04:00 blabla
Mar 09 16:04:02 blabla
Mar 09 16:04:05 blabla
Mar 09 16:04:15 blabla
Mar 09 16:05:06 blabla
Mar 09 16:05:23 blabla
Mar 09 16:05:25 blabla
... in this file I'm grepping... (5 Replies)