Recursively *.ext files using find


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Recursively *.ext files using find
# 1  
Old 04-26-2012
Recursively *.ext files using find

HI,

Getting the syntax error " find: missing conjunction" for the below code

Code:
D1_DIR=/x/y/z
D1_NAME=file_name
FILE_DIR=pset
for file in `find ${D1_DIR}/${D1_NAME} -name "*\.${FILE_DIR}" /dev/null {} \;`
do
                echo $file
done

#Trying to find all the files with *.pset extension in the folder ${D1_DIR}/${D1_NAME} recursively and trying to loop through each file.

please let me know the fix for the error.

thanks

Last edited by methyl; 04-26-2012 at 07:29 AM.. Reason: please use code tags
# 2  
Old 04-26-2012
Remove the below part from find command and run
Code:
 /dev/null {} \;

This User Gave Thanks to pravin27 For This Post:
# 3  
Old 04-26-2012
The error is coming from the superflous /dev/null and the extra punctuation.

The loop would be much more robust with while instead of for:
Code:
find "${D1_DIR}/${D1_NAME}" -name "*\.${FILE_DIR}" -print | while read file
do
                echo "${file}"
done

This User Gave Thanks to methyl For This Post:
# 4  
Old 04-26-2012
I have the list of files to be processed in another input file. Now with in the for/while loop i need to restrict my processing only for the files present in input file.

let me know how to achieve the same. thanks.

---------- Post updated at 05:54 AM ---------- Previous update was at 05:53 AM ----------

Quote:
Originally Posted by pravin27
Remove the below part from find command and run
Code:
 /dev/null {} \;


thanks a lot for your reply
# 5  
Old 04-26-2012
Please post a couple of example lines from "input file" making it clear whether the file contains full paths.
# 6  
Old 04-26-2012
Quote:
Originally Posted by methyl
The error is coming from the superflous /dev/null and the extra punctuation.

The loop would be much more robust with while instead of for:
Code:
find "${D1_DIR}/${D1_NAME}" -name "*\.${FILE_DIR}" -print | while read file
do
                echo "${file}"
done

I think the
Code:
/dev/null

is not superflous; it is just used wrongly. It might be necessary when any of the sub-directories in the search path do not have execute permissions. In such a case, it's better to redirect standard error to
Code:
/dev/null

.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find Large Files Recursively From Specific Directory

Hi. I found many scripts in the web of achieving this. But I like to use this one find /EDWH-DMT03 -xdev -size +10000 -exec ls -la {} \;|sort -n -k 5 > LARGE.rst But the problem is, why it still list out files with 89 bytes as the output? Is there anything wrong with the command? My... (7 Replies)
Discussion started by: aimy
7 Replies

2. Shell Programming and Scripting

How to recursively /usr/bin/find only readonly files?

I'm having trouble because, for some reason, cp -R missed a few files. And so did xcopy/s. Since I'm running Cygwin on Win10, I decided to see if robocopy would be more effective. The trouble is someone, maybe xcopy/s or cp -R dutifully set certain files to be read only so when I try a... (6 Replies)
Discussion started by: siegfried
6 Replies

3. 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

4. Shell Programming and Scripting

how to get only filename in a recursively find command

Hi i would like to ask on how to accomplish the FF: I want to execute a find command recursively and only get the filename something like i want only the last field set if is used ever the fieldvset as an redirection from the output of the find command For example: dir1/dir2/filename1... (2 Replies)
Discussion started by: jao_madn
2 Replies

5. Shell Programming and Scripting

Shell Script - find, recursively, all files that are duplicated

Hi. I have a problem that i can't seem to resolve. I need to create a script that list all the files, that are found recursively, with the same name. For example if a file exists in more than one directory with the same name it list all the files that he founds with all the info. Could someone... (5 Replies)
Discussion started by: KitFisto
5 Replies

6. Shell Programming and Scripting

Shell script to rename files with .1,.2,.3 ....ext respectively

Hey Guys.... Just need some help as I am not proficient in Unix shell script... Doubt: --------------- Suppose there will be some of the following files inside a directory called OUT ... Path: - /appdb1/product/batch/rms/OUT files inside OUT directory:- POSU_75002_20090127_20090129035442... (4 Replies)
Discussion started by: satyajit007
4 Replies

7. Shell Programming and Scripting

find and replace a search string recursively in files

Hi , I have a directory structure as dir and subdirectories and files under it and so on.now I need to find the files which contain the search string under every dir and subdir and replace . my search string is like searchstring=/a/b string to be replaced=/a/c/b please help. ... (7 Replies)
Discussion started by: mohanpadamata
7 Replies

8. Shell Programming and Scripting

checkingthe size of all the .txt , .ext files in all directories ..

hai, i am new to unix scripting & learning unix scripting and doing some assignments.... i have an assignment as follows, i want to check the size of the text file and .ext files in all directories, if any one of them is greater than 100mb , i have to display those files.. ... (2 Replies)
Discussion started by: G.K.K
2 Replies

9. UNIX for Dummies Questions & Answers

How to delete files with certain ext?

Hi All, How can I work on following request? Delete all the html files older than 29th November from the path - /dding/ting/tong/unixyang/output (4 Replies)
Discussion started by: tonyvirk
4 Replies

10. UNIX for Dummies Questions & Answers

diff on compressed files with tar.gz ext

how can I find out what is the difference between two tar.gz files without uncompressing them. thank you. (7 Replies)
Discussion started by: rakeshou
7 Replies
Login or Register to Ask a Question