Sponsored Content
Top Forums Shell Programming and Scripting finding multiple files using find command Post 302470627 by anurag.singh on Wednesday 10th of November 2010 03:29:37 PM
Old 11-10-2010
Code:
find -name file1.txt -a -name file2.txt

this will try to find a file with name "file1.txt" AND "file2.txt". No match, so no result.
For your need, may be you can use Logical OR and count the result.
Code:
find . \( -name file1.txt -o -name file2.txt \) | wc -l

If count is zero, no file exists,
If count is one, one file exists,
If count is two, both files exist.
This User Gave Thanks to anurag.singh For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

find - finding files.

I understand that to find a type of file using command find I could do "find -type f -name \*.htm -print". However, I wish to find all files BUT *.htm. Can I negate the search somehow? Again, I have peeked into the man files etc... If anyone has an answer, Thanks in Advance! (3 Replies)
Discussion started by: gsjf
3 Replies

2. UNIX for Dummies Questions & Answers

Finding Names in multiple files

What's the best way to see if a common name exists in two separate files? (3 Replies)
Discussion started by: Rally_Point
3 Replies

3. UNIX for Dummies Questions & Answers

Finding names in multiple files - second attempt

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)
Discussion started by: Rally_Point
2 Replies

4. Shell Programming and Scripting

I need to find one command from multiple files and need to print that file which contains neede com

Hi all i need your help .. I am having a multiple file in directory and i have find out the Rcopy word from these files and need to print those files which contains the Rcopy word Thanks and regards Vijay sahu (2 Replies)
Discussion started by: vijays3
2 Replies

5. Shell Programming and Scripting

multiple regex finding in files

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)
Discussion started by: learnbash
1 Replies

6. UNIX for Dummies Questions & Answers

Finding nth line across multiple files

I have several files (around 50) that have the similar format. I need to extract the 5th line from every file and output that into a text file. So far, I have been able to figure out how to do it for a single file: $ awk 'NR==5' text1.txt > results.txt OR $ sed -n '5p' text1.txt > results.txt... (6 Replies)
Discussion started by: oriqin
6 Replies

7. UNIX for Dummies Questions & Answers

grep command to find multiple strings in multiple lines in a file.

I want to search files (basically .cc files) in /xx folder and subfolders. Those files (*.cc files) must contain #include "header.h" AND x() function. I am writing it another way to make it clear, I wanna list of *.cc files that have 'header.h' & 'x()'. They must have two strings, header.h... (2 Replies)
Discussion started by: ritikaSharma
2 Replies

8. UNIX for Dummies Questions & Answers

Finding and Extracting uniq data in multiple files

Hi, I have several files that look like this: File1.txt Data1 Data2 Data20 File2.txt Data1 Data5 Data10 File3.txt Data1 Data2 Data17 File4.txt (6 Replies)
Discussion started by: Fahmida
6 Replies

9. Shell Programming and Scripting

Finding older files using find command

Hi All, I want to find files which are older than 15 days. I have written a command as below, find -mtime +15 -print I understand (System date - last modified time of a file) should be greater than or equal to 15 days. This command returns files which are 15 days old.. i.e... (1 Reply)
Discussion started by: nshan
1 Replies

10. Shell Programming and Scripting

finding matches between multiple files from different directories

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)
Discussion started by: bramya07
0 Replies
merge(1)						      General Commands Manual							  merge(1)

NAME
merge - three-way file merge SYNOPSIS
file1 file2 file3 DESCRIPTION
combines two files that are revisions of a single original file. The original file is file2, and the revised files are file1 and file3. identifies all changes that lead from file2 to file3 and from file2 to file1, then deposits the merged text into file1. If the option is used, the result goes to standard output instead of file1. An overlap occurs if both file1 and file3 have changes in the same place. prints how many overlaps occurred, and includes both alterna- tives in the result. The alternatives are delimited as follows: lines in file1 lines in file3 If there are overlaps, edit the result in file1 and delete one of the alternatives. This command is particularly useful for revision control, especially if file1 and file3 are the ends of two branches that have file2 as a common ancestor. EXAMPLES
A typical use for is as follows: 1. To merge an RCS branch into the trunk, first check out the three different versions from RCS (see co(1)) and rename them for their revision numbers: 5.2, 5.11, and 5.2.3.3. File 5.2.3.3 is the end of an RCS branch that split off the trunk at file 5.2. 2. For this example, assume file 5.11 is the latest version on the trunk, and is also a revision of the "original" file, 5.2. Merge the branch into the trunk with the command: 3. File 5.11 now contains all changes made on the branch and the trunk, and has markings in the file to show all overlapping changes. 4. Edit file 5.11 to correct the overlaps, then use the command to check the file back in (see ci(1)). WARNINGS
uses the ed(1) system editor. Therefore, the file size limits of ed(1) apply to AUTHOR
was developed by Walter F. Tichy. SEE ALSO
diff3(1), diff(1), rcsmerge(1), co(1). merge(1)
All times are GMT -4. The time now is 07:13 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy