Find result using for loop


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Find result using for loop
# 1  
Old 08-10-2010
Find result using for loop

I want to print each file i found using the find command. And not able to list the files at all here is the code

Code:
SEARCH_DIR="/filesinfolder";
PATH_COUNT=0
 
for result in "'/usr/bin/find  $SEARCH_DIR  -daystart \( \( -name 'KI*' -a -name '*.csv' \) -o  -name '*_xyz_*' \)  -mtime 1'"
 
do
  PATH_RESULTS[$PATH_COUNT]="$result"
  echo "${PATH_RESULTS[$PATH_COUNT]}"
  # more code
  #
  let PATH_COUNT=PATH_COUNT+1
done

# 2  
Old 08-10-2010
If you are using Kshell, something like this might work for you:

Code:
find . -name "*.cvs" | while read filename
do
     # code to manipulate filename
done

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

CUT command not giving correct result inside loop

Hi, i have a source file and have 3 columns and separated by "|" .i want to split this 3 columns in different variable.When i am executing this values indivisually giving correct result but when the same execute inside a for loop,it's giving issues. Src file(jjj.txt) -------... (8 Replies)
Discussion started by: raju2016
8 Replies

2. Shell Programming and Scripting

Bash loop to result in one file

Is there a way to use a directory with multiple files (.bam) to create one new file? The below bash loop will create a new file (header.sam) for each of the bam files. However, I only need to use 1 of the bam file to make 1 header file. I attempted a code as well, but not sure if thats... (5 Replies)
Discussion started by: cmccabe
5 Replies

3. UNIX for Dummies Questions & Answers

Strange result using find command.

I created a file with the permissions of 776. When I ran the command find /root/Desktop -perm -644 -type f The created file shows up as part of the results. Doesn't -perm -mode mean that for global, only 4(read) and 2(write) can be accepted ? (2 Replies)
Discussion started by: Hijanoqu
2 Replies

4. Shell Programming and Scripting

Remove ./ from result when i do find

Hi All, When i do find command i am getting result which append ./ before the file name. For example if i am trying to search aaa.txt in current directory i am using find like this: $ find . -name aaa.txt result: ./aaa.txt Now i want to remove "./" from the file name. Can some body... (5 Replies)
Discussion started by: VasuKukkapalli
5 Replies

5. Shell Programming and Scripting

Match look up file and find result

Hi I ahve a lookup file wiht seven words CD HT CAD HT T1D T2D BDanother file contain data like this CHRM1 P11229 Pirenzepine DAP000492 Peptic ulcer disease Approved T2D CHRM1 P11229 Glycopyrrolate DAP001116 Anesthetic Approved T2D CHRM1 P11229 ... (7 Replies)
Discussion started by: manigrover
7 Replies

6. UNIX for Dummies Questions & Answers

Find command - result order

Hi! Could you please explain why the result order isn't in reverse time order as it is requestet by "xargs ls -ltr" command (ksh shell)? There are about 5000 files in dir. $ find . -name "*201010*" -print |xargs ls -ltr |tail -rw-r--r-- 1 oracle oinstall 54326 Nov 25 20:32... (2 Replies)
Discussion started by: laki47
2 Replies

7. UNIX Desktop Questions & Answers

find result

When searching for some files which match some specific criteria with find from the root directory, I got a listing of a bunch of files that say "Permission Denied". How can do my search and not show the files that I don't have the permission to list? Thanks, (3 Replies)
Discussion started by: Pouchie1
3 Replies

8. Shell Programming and Scripting

Pick up the return code for every iteration and display the result only once in loop.

Hi All, I amlearning UNIX scripting. I have a small query. I would be thankful if any one helps me out. I have a below piece of code which delets the files. If file dosent have the permissions to delete a particular file I have used 2>>operator to track the error code. But my objective is... (1 Reply)
Discussion started by: manas6
1 Replies

9. Shell Programming and Scripting

result of find

Hey, I am using 'find' to check the existence of a file which is created today, and this is what I have find . -name $filename -mtime +0 -exec ls {} \; my problem is I need to know what the above command actually get anything, so can anyone give me some pointer on how to do... (1 Reply)
Discussion started by: mpang_
1 Replies

10. UNIX for Advanced & Expert Users

find command not returning any result

I am looking for all the header files (*.h).. which as per documentation of the UNIX system shouldbe there. I am using find / -name *.h -print But it does't give anything. My question is under what condition the "find" condition will fail to find the file? What is the work around. ... (4 Replies)
Discussion started by: rraajjiibb
4 Replies
Login or Register to Ask a Question