Using an input (?) file to search another


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Using an input (?) file to search another
# 8  
Old 10-12-2010
rdcwayx: I realized it works better if you do fgrep instead of just grep... but thanks!
This User Gave Thanks to oriqin For This Post:
# 9  
Old 10-13-2010
Yes, fgrep is faster and has no metacharacters.
# 10  
Old 10-13-2010
Just a note, fgrep is deprecated and grep -F is now favored instead..
# 11  
Old 10-14-2010
Did egrep get decapitated, too? Smilie
# 12  
Old 10-14-2010
Yup, grep -E Smilie and so is rgrep...
# 13  
Old 10-14-2010
Never got into rgrep, too GNU. Besides, I like to do that with parallelism:

Code:
find ... -type f -follow |xdemux 32 'nice -19 fxargs2 grep ...'

xdemux is a simple C program that opens $i popen()'s to write command $2 and writes lines in rotation. Did I rewrite something already there?

fxargs2 is 'xargs -n 1000' simplified, fortified and sped up, where each line is one arg and no command line is created = no quoting challenges, just direct fork and exec "$* files".

Since the grep is CPU intensive, I get to use all 16 CPUs and call the 32 sequences of grep commands with 1000 files or 256K each, whichever comes first. I usually set N to CPU cores x 2, since there is I/O and some grep commands get bigger files than others.

I suspect I am an unrepentant power user . . . . Smilie
# 14  
Old 10-14-2010
Funny, that is my experience too that usually the sweet spot is at two threads or subprograms per core in a situation with IO. That my style too. No use letting all those expensive CPUs sit idly by. I am wondering about fxargs2. Since with xargs there are no quoting challenges either, so what could be improved?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Reducing input file size after pattern search

I have a very large file with millions of entries identified by @M. I am using the following script to "extract" entries based on specific strings/patterns: #!/bin/bash if ] then file=$1 else echo "Input_file passed as an argument $1 is NOT found." exit; fi MID=(NULL "string-1"... (10 Replies)
Discussion started by: Xterra
10 Replies

2. Shell Programming and Scripting

Search pattern in a file taking input from another file

Hi, Below is my requirement File1: svasjsdhvassdvasdhhgvasddhvasdhasdjhvasdjsahvasdjvdasjdvvsadjhv vdjvsdjasvdasdjbasdjbasdjhasbdasjhdbjheasbdasjdsajhbjasbjasbhddjb svfsdhgvfdshgvfsdhfvsdadhfvsajhvasjdhvsajhdvsadjvhasjhdvjhsadjahs File2: sdh hgv I need a command such that... (8 Replies)
Discussion started by: imrandec85
8 Replies

3. Linux

Search a template file and replace with input

Hi I have a CommonTemplateStop.template file . Inside the file i need to replace the variables DepName and CompInsName with the values(Trade and TradeIns) specified in the script. I have written the below .sh script in linux server which will read the .template file and has to replace the 2... (8 Replies)
Discussion started by: samrat dutta
8 Replies

4. Shell Programming and Scripting

UNIX Scripting help to input string and search a file to find

Hi Don, this is not homework question. I work for a Credit card company and my development goal this year is to learn Unix. I would love if others can help me get started, thanks. Hi everyone I am new to Unix and need help writing a script that can ask user for an input, then search that input... (2 Replies)
Discussion started by: 12ic11
2 Replies

5. Shell Programming and Scripting

UNIX Scripting help to input string and search a file to find

Hi everyone, I am new to Unix and need help writing a script that can ask user for an input, then search that input within a file I know will have to use the read and grep commands, anyone can give me somewhere to start would help Task: Write a script to display which volume pool a given... (1 Reply)
Discussion started by: 12ic11
1 Replies

6. UNIX for Dummies Questions & Answers

UNIX Scripting help to input string and search a file to find

Hi everyone, I am new to Unix and need help writing a script that can ask user for an input, then search that input within a file I know will have to use the read and grep commands, anyone can give me somewhere to start would help Task: Write a script to display... (1 Reply)
Discussion started by: 12ic11
1 Replies

7. Shell Programming and Scripting

Bash to search file based off user input then create new file

In the below bash a file is downloaded when the program is opened and then that file is searched based on user input and the result is written to a new file. For example, the bash is opened and the download.txt is downloaded, the user then enters the id (NA04520). The id is used to search... (5 Replies)
Discussion started by: cmccabe
5 Replies

8. Shell Programming and Scripting

Search on date range of file based on user input

Hello I would like to ask for help with a script to search a directory that contains many log files and based on a users input after being prompted, they enter a date range down to the hour which searches the files that contain that range. I dont know how to go about this. I am hoping that the... (5 Replies)
Discussion started by: lostincashe
5 Replies

9. Solaris

Keyword search input from a file

Hi, I have a file which got only one column and got some keywords. I have another file where the keywords used in the first file are repeated in the second file. Now I would like to know how many times each keyword from the first file is repeated in the second file. Request your help on... (1 Reply)
Discussion started by: pointers
1 Replies

10. Shell Programming and Scripting

Merge of two input file by search

Hi i am running a issue with the way i handel open file in perl i have the following input file <File1> D33963|BNS Default Swap|-261564.923909249| D24484|BNS Default Swap|-53356.6868058492| D24485|BNS Default Swap|-21180.9904679111| D33965|BNS Default Swap|154181.478745804|... (6 Replies)
Discussion started by: kykyboss
6 Replies
Login or Register to Ask a Question