fgrep command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting fgrep command
# 8  
Old 12-23-2009
All the Commands are working fine.But the problem is , the commands are taking huge time when the files have records around 5M
# 9  
Old 12-23-2009
How long does it take exactly?
# 10  
Old 12-23-2009
Code:
#!/bin/sh

PATTERNS=`cat patternfile`

for pat in $PATTERNS
do
cat File2 | grep "^$pat\>"
done

this command is fine . but the problem is this is very slow if have millions records

---------- Post updated at 08:17 AM ---------- Previous update was at 08:11 AM ----------

the above command is very slow if we have millions of records in the file

Last edited by pludi; 12-23-2009 at 09:18 AM.. Reason: code tags, please...
# 11  
Old 12-23-2009
Quote:
Originally Posted by morbid_angel
Code:
#!/bin/sh

PATTERNS=`cat patternfile`

for pat in $PATTERNS
do
cat File2 | grep "^$pat\>"
done

this command is fine . but the problem is this is very slow if have millions records

---------- Post updated at 08:17 AM ---------- Previous update was at 08:11 AM ----------

the above command is very slow if we have millions of records in the file

Why are you using cat?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Need to use fgrep and egrep in a single command

I have a source file which is something like : C/*M/ / ***HMACCT ** MONTH FOR CURRENT MINUS 14 CAL DAY C/*D/ / ***HMACCT ** DAY FOR CURRENT MINUS 14 CAL DAY C/*X/ / ***HMACCT ** CENTURY FOR CURRENT MINUS 14 CAL DAY C/*Y/ / ***HMACCT **... (5 Replies)
Discussion started by: gotamp
5 Replies

2. UNIX for Dummies Questions & Answers

Fgrep -v

Using the fgrep command with the -v option. I have two files: file1: dog 1 cat 3 bird 5 fish 7file2: dog catUsing fgrep -v file2 file1 According to the fgrep man page, the output should be bird5 fish 7 but I can't seem to get it to work. Any help would be appreciated. (2 Replies)
Discussion started by: jimmyf
2 Replies

3. Shell Programming and Scripting

fgrep command: Perl programming help needed..Kindly advise

Hi, I am novice in PERL enviornment. I have a text files withso many entries in rows and columns. I have to pick up entries named as "Uniprot ID" in the file and create a new text file with list of particular Uniprot ID entries. Can anybody guide regarding this.. I came to know abut fgrep... (1 Reply)
Discussion started by: manigrover
1 Replies

4. Shell Programming and Scripting

Pipe and fgrep

Hi , Please help me resolve the below issue. I need to combine the below two command into one. grep 'ImanItemP' import.report| tr -s ' ' | cut -f2 -d ' ' > tmp.txt fgrep -v -f tmp.txt input.txt > reuired file.txt Thanks Ramesh (4 Replies)
Discussion started by: ramesh12621
4 Replies

5. Shell Programming and Scripting

Problem in Using fgrep Command with pattern file option

Hi, i am using fgrep command with following syntax fgrep -v -f pattern_file_name file file contains few line and have the pattern which i am giving in pattern file. My Problem is : its is not giving any output. while i am using fgrep -f pattern_file_name file it is showing all... (4 Replies)
Discussion started by: emresearch
4 Replies

6. Shell Programming and Scripting

Awk Vs Fgrep

Hi All, I have 2 files new.txt and old.txt cat new.txt sku1|v1|v2|v3 sku2|v11|v22|v33 sku3|v11|v22|v33 cat old.txt sku1|vx1|vx2|vx3 sku2|vx11|vx22|vx33 sku3|v11|v22|v33 The key column in both files are first column itself. I want to get records in... (6 Replies)
Discussion started by: morbid_angel
6 Replies

7. Shell Programming and Scripting

fgrep to file plus some

Hi, I know that I can grep desired data to a file but is there a way to add an additional field of data to the output in addition to what is found. I want to add a login id to the data that is found in the grep. Is this even possible? Thanks for your help. Toni (14 Replies)
Discussion started by: ski
14 Replies

8. UNIX for Dummies Questions & Answers

FGREP question

Hi, I need fgrep to search all files in the subdirectories in /var/spool/postfix/defer/... How can I issue such a command? (3 Replies)
Discussion started by: mojoman
3 Replies

9. UNIX for Dummies Questions & Answers

Usage of fgrep -f command in kshell

Hi, Can I know the usage of fgrep -f command in kshell. Reqirement: Need to search for list of patterns in list of files and display all the files which are having atleast one in the patterns list. I hope fgrep -f will serve this purpose within a loop. But I am not successfull in doing this.... (0 Replies)
Discussion started by: divv
0 Replies

10. UNIX for Advanced & Expert Users

fgrep

Hi Guys, Can anyone explain why I'm getting error below? when I execute in other server there is no error, what could be the reason. $ fgrep -f timecell.txt ldap_prev.dat wordlist too large $ wc -l timecell.txt ldap_prev.dat 372461 timecell.txt 3722878 ldap_prev.dat Thanks in... (2 Replies)
Discussion started by: krishna
2 Replies
Login or Register to Ask a Question