Grep can accept multiple filenames as arguments. Suppose you're looking in file1, file2 and file3 for the name treesloth. You can simply do:
The system should assume, unless you use switches to modify it, that the first argument is the regular expression you're looking for, and all additional arguments are files to search in.
I'm not completely sure what you mean when you say that you "don't know the name up front". Do you mean that you just don't happen to know right now what you'll be searching for, but when the time comes you'll have a definite search term? If so, you could do something like:
That will show, for each search term, how many different files it appears in. Alternately, this:
However, I suspect that this comes closest to what you need:
That will give you the search term, followed by the number of files it appears in, so long as that number is 2 or more. You can make it just show the search term by removing the "$filecount" from the 4th line. That sounds close to what you describe. If not, let us know and I'm sure we can whip it into shape.
Oh, this is all in CSH.
Sadly, I haven't had a chance to check out the Thai food around here yet. It's on the list, but if you recall the name, I'll bump it to the top. Have fun.
I'm interested in writing a report script using BASH that searches all of the files in a particular directory for a keyword and printing a list of files containing this string...
In fact this reporting script would have searches for multiple keywords, so I'm interested in making multiple... (2 Replies)
So, I have a directory tree that has many files named thusly:
X_REVY.PDF
I need to find any files that have the same X portion (which can be nearly anything) as any another file (in any directory) but have different Y portions (which can be any number from 1-99).
I then need it to return... (3 Replies)
I am running a UNIX script to get unused files and their sizes from the server. The issue is arising due to the spaces present in the filename/folder names.Due to this the du -k command doesn't work properly.But I need to calculate the size of all files including the ones which have spaces in them.... (4 Replies)
Dear Gurus,
I have 57 tab-delimited different text files, each one containing entries in 3 columns. The first column in each file contains names of objects. Some names are present in more than one file. I would like to find those names and store them in a separate text file, preferably with a... (6 Replies)
Hi all...
Can somebody pls help me with this...
I have a directory (dir1) which has many subdirectories(vr001,vr002,vr003..) with each subdir containing similar text file(say ras.txt).
I have another directory(dir2) which has again got some subdir(vr001c,vr002c,vr003c..) with each subdir... (0 Replies)
I have 1000's of directories which is named as numbers. Each directory contains multiple files. Each of these directories have a file named "att". I need to rename all the att files by adding the directory name followed by "_" then att for each of the directories.
Directories
120
att... (2 Replies)
I am trying to search for 2 files using the find command as below
find -name file1.txt -a -name file2.txt
It doesn't give a result although the files exist in the folder, however when i try the following
find -name file1.txt -o -name file2.txt
It does give me the result.
./file2.txt... (4 Replies)
Hello folks,
I have a text file aa.txt that contains below text
(\')|(\-\-)
((\%3D)|(=))
20%0d%
i want to search each line pattern in /opt/1.log and /opt/2.log. Can some one suggest (1 Reply)
I couldn't find the original thread that I created and since I didn't get a definitive answer, I figured I'd try again. Maybe this time I can describe what I want a little better.
I've got two files, each with thousands of names all separated by new line. I want to know if 'name in file1'... (2 Replies)
I am trying to find all files in a directory whose name has a real number larger then the number I am looking for.
For example:
.
|-- delta.1.5.sql
|-- delta.2.1.sql
|-- delta.2.2.sql
|-- delta.2.3.sql
|-- delta.2.4.sql
`-- delta.2.5.sql
I know my database is at 2.2 so I want an... (2 Replies)