get all files from a directory and pass the files for processing


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting get all files from a directory and pass the files for processing
# 1  
Old 08-20-2009
get all files from a directory and pass the files for processing

Hi All,
I have a directory in which there will be several files. i want to get all the files and pass it to a piece of code for processing on the files.
This is the piece of code which does the processing.

Code:
 
tr "\n" "|" < (log file name) | tr "$" "\n" > output
echo '  ' >>output
 while read line
 do
 sh ParseLog.sh "$line"
 echo $?
 done<output

say i have a directory /user/resin_log , how to get all the files in this directory and pass one by one to this piece of code. Saw a similar query, but couldnt derive anything from that. Please Help. Thanks in advance.

---------- Post updated at 01:10 AM ---------- Previous update was at 12:01 AM ----------

done it with this piece of code. Thank you
Code:
 
ls -lurt /user/resin_log | awk -F ' ' '{print $9}' > file_list
while read line
do
file_name=$line
tr "\n" "|" < (log file name) | tr "$" "\n" > output
echo '  ' >>output
while read line
do
sh ParseLog.sh "$line"
echo $?
done<output
fi
 done <file_list

# 2  
Old 08-20-2009
cd $DIR
for i in `find . -type f`
do
sh ParseLog.sh "$i"
done
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Directory containing files,Print names of the files in the directory that are exactly same content.

Given a directory containing say a few thousand files, please output a list of all the names of the files in the directory that are exactly the same, i.e. have the same contents. func(a_directory_name) output -> {“matches”: , ... ]} e.g. func(“/home/my/files”) where the directory... (7 Replies)
Discussion started by: anuragpgtgerman
7 Replies

2. Shell Programming and Scripting

Append string to all the files inside a directory excluding subdirectories and .zip files

Hii, Could someone help me to append string to the starting of all the filenames inside a directory but it should exclude .zip files and subdirectories. Eg. file1: test1.log file2: test2.log file3 test.zip After running the script file1: string_test1.log file2: string_test2.log file3:... (4 Replies)
Discussion started by: Ravi Kishore
4 Replies

3. Shell Programming and Scripting

Delete all files if another files in the same directory has a matching occurrence of a specific word

he following are the files available in my directory RSK_123_20141113_031500.txt RSK_123_20141113_081500.txt RSK_126_20141113_041500.txt RSK_126_20141113_081800.txt RSK_128_20141113_091600.txt Here, "RSK" is file prefix and 123 is a code name and rest is just timestamp of the file when its... (7 Replies)
Discussion started by: kridhick
7 Replies

4. UNIX for Advanced & Expert Users

Find all files in the current directory excluding hidden files and directories

Find all files in the current directory only excluding hidden directories and files. For the below command, though it's not deleting hidden files.. it is traversing through the hidden directories and listing normal which should be avoided. `find . \( ! -name ".*" -prune \) -mtime +${n_days}... (7 Replies)
Discussion started by: ksailesh1
7 Replies

5. Shell Programming and Scripting

AIX system.... deleting files in remote directory after retrieving files

Hi Friends, I am new to this , I am working on AIX system and my scenario is to retrive the files from remote system and remove the files from the remote system after retreving files. I can able to retrieve the files but Can't remove files in remote system. Please check my code and help me out... (3 Replies)
Discussion started by: vinayparakala
3 Replies

6. Shell Programming and Scripting

Apply 'awk' to all files in a directory or individual files from a command line

Hi All, I am using the awk command to replace ',' by '\t' (tabs) in a csv file. I would like to apply this to all .csv files in a directory and create .txt files with the tabs. How would I do this in a script? I have the following script called "csvtabs": awk 'BEGIN { FS... (4 Replies)
Discussion started by: ScKaSx
4 Replies

7. Shell Programming and Scripting

Delete all files if another files in the same directory has a matching occurence of a specific word

Hello, I have several files in a specific directory. A specific string in one file can occur in another files. If this string is in other files. Then all the files in which this string occured should be deleted and only 1 file should remain with the string. Example. file1 ShortName "Blue... (2 Replies)
Discussion started by: premier_de
2 Replies

8. Shell Programming and Scripting

mget * (obtein files from current directory but not the files form sub-directories)

Hello, Using the instruction mget (within ftp) and with "Interactive mode off", I want to get all files from directory (DirAA), but not the files in sub-directories. The files names don't follow any defined rule, so they can be just letters without (.) period Directory structure example: ... (0 Replies)
Discussion started by: Peter321
0 Replies

9. Shell Programming and Scripting

how to extract files one by one from a directory and let some processing happen

how to extract files one by one from a directory and let some processing be done on the file I have a directory by name INTRN which has files like INTR.0003080248636814 INTR.0003080248636816 INTR.0003080248636818 . . . . and so on and in a script... (5 Replies)
Discussion started by: saniya
5 Replies

10. Shell Programming and Scripting

Processing files within a directory one by one

Hi How to create a shell script which takes in to account all the files present within a directory DIR one by one e.g. suppose i have a directory named DIR where there are files with the extension .ABC i want to create shell script which processes all these files one by one. ... (1 Reply)
Discussion started by: skyineyes
1 Replies
Login or Register to Ask a Question