Can 'file' be used recursively?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Can 'file' be used recursively?
# 1  
Old 10-29-2009
Can 'file' be used recursively?

I'd like find all the files with names containing a certain pattern, in a directory hierarchy - not just a single directory.

For example:
file *.txt

But throughout the entire hierarchy.

Can this be done? If so, how?

Thank you
# 2  
Old 10-29-2009
Code:
find / -name "*.txt"

# 3  
Old 10-29-2009
Quote:
Originally Posted by jlliagre
Code:
find / -name "*.txt"

Unfortunately, I need the info that 'file' produces (the file types).

Is there a way to do it with 'file'?
# 4  
Old 10-29-2009
Yep, I missed the file requirement.
Code:
find / -name "*.txt" -exec file {} +

# 5  
Old 10-30-2009
Thank you!
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find and rename file recursively

Hi, I have a directory which contains multiple files with .txt extension, i want to rename all these file to .bak extension using find command, this is what i've tried, please help me to correct this : find /home/application/test -name '*.txt' -exec rename 's/txt/bak/' {} \; seems to... (8 Replies)
Discussion started by: mukulverma2408
8 Replies

2. Shell Programming and Scripting

Change permission on a file recursively

Hi, this is the structure of the directory /local/home/app/cases under cases directory, below are the sub directories and each directory has files. /local/home/app/cases/1 /local/home/app/cases/2 /local/home/app/cases/3 /local/home/app/cases/4 File types are .txt .sh and so... (5 Replies)
Discussion started by: lookinginfo
5 Replies

3. Shell Programming and Scripting

Recursively Searcing file in the directories

i have directory dgf in the dgf( some other Sub-dir are there) 00 01 02 03 04 in all the Sub directory there is a SG.csv .. i want the scripts should run one by one Sub-dir and print the result for that particular Sub-dir ..then go to next Sub-Dir and print the result....... please... (6 Replies)
Discussion started by: Aditya.Gurgaon
6 Replies

4. Shell Programming and Scripting

Transpose recursively into delimited file

I would like to write a script that takes something like this: Line 1 Line 2 Line 3 Line 4 Line 6 Line 7 Line 8 Line 9 etc.... And makes it to look like this: Line 1|Line 2|Line 3|Line 4| Line 6|Line 7|Line 8|Line 9| etc. I would think it would be fairly easy to use two loops,... (4 Replies)
Discussion started by: jcs
4 Replies

5. Shell Programming and Scripting

how to find a pattern from an external file in a directory containing multiple file recursively

Hi, Need your help in this. I have an input file that has multiple enrollment_number, somewhat like 1234567 8901234 9856321 6732187 7623465 Now i have to search and delete these enrollment_number recursively from all the files that are within multiple sub-directories of a... (10 Replies)
Discussion started by: mukulverma2408
10 Replies

6. UNIX for Dummies Questions & Answers

Recursively listing of the file

Hi, I want to list out the files for a particular date recursively along with timestamp and directory name . I tried using command ls -lRt this list out all the files along with directory structure but i want for a particular date so i tried with ls -lRt | grep 20110809 in... (9 Replies)
Discussion started by: Abhi2910
9 Replies

7. Red Hat

Copy certain file types recursively while maintaining file structure on destination?

Hi guys, I have just been bothered by a fairly small issue for some time now. I am trying to search (using find -name) for some .jpg files recursively. This is a Redhat environment with bash. I get this job done though I need to copy ALL of them and put them in a separate folder BUT I also... (1 Reply)
Discussion started by: rockf1bull
1 Replies

8. Shell Programming and Scripting

Insert file.txt recursively

Anyone knows how I can change this script so that it works recursively as well (meaning: *.c files in sub directories will get changed as well)? for file in *.c do cat file.txt "$file" > tempfile cat tempfile > "$file" done rm tempfile (5 Replies)
Discussion started by: psve
5 Replies

9. Shell Programming and Scripting

Changing file permission recursively

I have a directory named DIR. The contents of the directory is something like: a.sh b.sh cghsk.sh assjsjkd gdshddll DFG/ ... ... Where only DFG/ is a folder. I want to grant execute permission to all(a+x), for all the files directly under the DIR directory except the files that... (4 Replies)
Discussion started by: proactiveaditya
4 Replies

10. UNIX for Dummies Questions & Answers

Need to cut a string from a file recursively.

I have a file exep_file.txt with contents similar to, xyx request 1329207. sdf sedf sg gds request 1329207. as as fa df sdf request 1329207. xyx request 1329209. sdf sedf sg gds request 1329209. as as fa df sdf request 1329209. I need an output like 1329207 1329209 ... (2 Replies)
Discussion started by: happyrain
2 Replies
Login or Register to Ask a Question