Grep from multiple files


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Grep from multiple files
# 1  
Old 05-13-2009
Grep from multiple files

Hello,

How do I grep from multiple, specific file names. For example I have a directory that has numerous files named bsm0a.alarm_output.xxxxxx (the x's will be the date).

I need to be able to grep any string that contains the acronym ACN or the word packets, but I will only need them from specific files. For example, I need to be able to grep from bsm0a.alarm_output.051009, bsm0a.alarm_output.051109 & bsm0a.alarm_output.051109 and nothing else.

Thanks.
# 2  
Old 05-13-2009
What have you tried, and where do you get stuck?

Regards
# 3  
Old 05-13-2009
I havent tried anything yet. I am fairly new to Unix.
# 4  
Old 05-13-2009
This is the common syntax of grep:

Code:
grep '<pattern>' file1 file2...filen

Use the search function for examples and read the man page of grep.

Regards
# 5  
Old 05-13-2009
Worked great. Thanks for your help.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Grep strings on multiple files and output to multiple files

Hi All, I want to use egrep on multiple files and the results should be output to multiple files. I am using the below code in my shell script(working in Ksh shell). However with this code I am not attaining the desired results. #!/bin/ksh ( a="/path/file1" b="path/file2" for file in... (4 Replies)
Discussion started by: am24
4 Replies

2. Shell Programming and Scripting

Grep multiple files

Hello, I am trying to grep, in bash, multiple specific files at once. I understand you can grep parameters file1 file2... fileN. My question is how to do this when the specific files are not constant in name or quantity? (min 2 files, max 24 files) Example 1: grep parameters file1 file2... (3 Replies)
Discussion started by: speedy1354
3 Replies

3. UNIX for Dummies Questions & Answers

Grep from multiple files by column name

I have 40 files with varying number of columns They however do have identical column names for the overlapping columns I would like to grep some info from these specific colums e.g file1 id beta se direction N 2 .5 .01 + 1000 5 -.6 .02 - 2000 file2 id ... (6 Replies)
Discussion started by: MFAB
6 Replies

4. Shell Programming and Scripting

Grep multiple strings in multiple files

Hi, every one! I have a file with multiple strings. file1 ATQRGNE ASQGVKFTE ASSQYRDRGGLET SPEQGARSDE ASSRDFTDT ASSYSGGYE ASSYTRLWNTGE ASQGHNTD PSLGGGNQPQH SLDRDSYNEQF I want to grep each string in hundreds of files in the same directory, further, I want to find out the string... (7 Replies)
Discussion started by: xshang
7 Replies

5. UNIX Desktop Questions & Answers

How do you [e]grep for multiple values within multiple files?

Hi I'm sure there's a way to do this, but I ran out of caffeine/talent before getting the answer in a long winded alternate way (don't ask ;) ) The task I was trying to do was scan a directory of files and show only files that contained 3 values: I940 5433309 2181 I tried many variations... (4 Replies)
Discussion started by: callumw
4 Replies

6. Shell Programming and Scripting

grep from multiple lines in several gz files

Hello all, I have been struggling to get grep work to my requirements. Basically I have to filter out patterns spread across multiple lines over hundreds of .gz files in a folder. And the output needs to be piped to a file. Here is the example: folder name: logs files in this folder:... (4 Replies)
Discussion started by: mandhan
4 Replies

7. UNIX for Dummies Questions & Answers

Grep multiple strings in multiple files using single command

Hi, I will use below command for grep single string ("osuser" is search string) ex: find . -type f | xarg grep -il osuser but i have one more string "v$session" here i want to grep in which file these two strings are present. any help is appreciated, Thanks in advance. Gagan (2 Replies)
Discussion started by: gagan4599
2 Replies

8. Shell Programming and Scripting

Grep in subdir, multiple files

Hi, I m trying to have script to grep a pattern in all files under a directory. I use Sun Solaris, the below want doesnt do exactly what I want. find /home/xxx/ tagHeu | while read FILE; do grep text $FILE && echo 1 grep text $FILE || echo 0 done I also tried running: find... (2 Replies)
Discussion started by: s3rro
2 Replies

9. UNIX for Dummies Questions & Answers

Grep from multiple files

Hello, I need to grep from multiple files that begin with the same text. For example, I have files named alert_audit324, alert_audit325, alert_audit326, etc. Is there a way I can use a wildcard and grep from any file that begins with alert_audit? Thanks. (1 Reply)
Discussion started by: robertson1995
1 Replies

10. UNIX for Advanced & Expert Users

grep count across multiple files

I have a number of simulation log files and I want to get a total count of the "PASSED" expression in them. If I use grep -c <files>, grep would give a tally for each file. I just want one number, the total count. How do I do that? (4 Replies)
Discussion started by: CrunchMunch
4 Replies
Login or Register to Ask a Question