Visit Our UNIX and Linux User Community


finding multiple file types with "-o"


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers finding multiple file types with "-o"
# 1  
Old 07-29-2002
Question finding multiple file types with "-o"

i was just wondering if any one had a good example of finding mutliple file types with the -o option or any other alternatives.

find . \( -name "*.txt" -o -name "*.tag" \)

for some reason i'm not having much luck and the man page isn't very descriptive.

what i am trying to do is find all files recursively with the extension of txt OR tag.

Thanks in anticipation.
Shakey21
# 2  
Old 07-30-2002
Computer

try this
find . -name "*"t[xa][tg]

this will also give you files ending on tat and txg,
but if you send your request afterwads trough an egrep like this find . -name "*"t[xa][tg] | egrep -v '(.tat|.txg)' you should get a good result Smilie
# 3  
Old 07-30-2002
thanks

but nup, it doesn't seem to work

i tried this:

find . -name "*"[pl][pm]

(but it doesn't seem to pick up the *.pl files) and i tried variations of this also....


and I would grep it however (i should have mentioned it before) I wish to add some extra parameters on the find command line. ie find . \( -name "*.txt" -o -name "*.tag" \) -exec grep -il "text" {} \;


additionally:

does the pipe character substitute an OR command only for a single character? ie find . -name "*.p[l|m]"

this works, however I am looking for 3 digit and different file extensions.
Shakey21
# 4  
Old 07-30-2002
Smilie
you don't need the pipe when you use square brackets
it works like this

"*"t[ax][gt] means everything ending on "t" "a or x" "g or t" this is tag,tat,txt,txg

when you write "*"[pl][pm] , you search for everything ending on
pp, pm, lp, lm and not "pl"

so everything between the brackets represents 1 position
# 5  
Old 07-30-2002
P.S. you can add as many characters as you whish between a set of brackets
so [aze][aze] stands for aa,az,ae,za,zz,ze,ea,ez,eeSmilie
# 6  
Old 07-30-2002
I just tried:
find . \( -name "*.c" -o -name "*.txt" \)
and I cannot get it to fail.

Could you be using ann older version of "find" that still requires a -print option?
# 7  
Old 07-30-2002
ok, i get that

hmmm, the find might be an older version then, because it does work when I use the print command. Any way of finding what version it is?

thank you all for the help!!!
Shakey21
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #448
Difficulty: Medium
Quirky Linux and Puppy Linux were both created by Barry Kauler.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

3. Shell Programming and Scripting

Using a single "find" cmd to search for multiple file types and output individual files

Hi All, I am new here but I have a scripting question that I can't seem to figure out with the "find" cmd. What I am trying to do is to only have to run a single find cmd parsing the directories and output the different file types to induvidual files and I have been running into problems.... (3 Replies)
Discussion started by: swaters
3 Replies

4. Shell Programming and Scripting

finding the strings beween 2 characters "/" & "/" in .txt file

Hi all. I have a .txt file that I need to sort it My file is like: 1- 88 chain0 MASTER (FF-TE) FFFF 1962510 /TCK T FD2TQHVTT1 /jtagc/jtag_instreg/updateinstr_reg_1 dff1 (TI,SO) 2- ... (10 Replies)
Discussion started by: Behrouzx77
10 Replies

5. Shell Programming and Scripting

AWK for multiple line records RS="^" FS="#"

I have to pull multiple line records with ^ as the record separator(RS)... # should be my field separator (FS)... Sample record is: ^-60#ORA-00060: deadlock detected while waiting for resource ORA-00001: unique constraint (SARADM.TCKNUM_PK) violated#PROC:AVAILABLE_FOR_GETNXTTIC#02/27/2012... (7 Replies)
Discussion started by: Vidhyaprakash
7 Replies

6. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

7. Shell Programming and Scripting

"sed" to check file size & echo " " to destination file

Hi, I've modified the syslogd source to include a thread that will keep track of a timer(or a timer thread). My intention is to check the file size of /var/log/messages in every one minute & if the size is more than 128KB, do a echo " " > /var/log/messages, so that the file size will be set... (7 Replies)
Discussion started by: jockey007
7 Replies

8. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies

9. Shell Programming and Scripting

Scripting multiple file "puts" in sFTP...

I need to send multiple files to a remote server via sFTP. I had everything set up to connect and send a single file automatically using a batch file and key authentication. Recently, however, the process has changed and we now need to send multiple files, one at a time, pausing for up to ten... (5 Replies)
Discussion started by: Cbish68
5 Replies

Featured Tech Videos