Can any body give me a solution to this...

Hi friends..
I am using the below command to search few files from many folders which is under one folder..

i mean let say the path is A/B/C...and inside C...i have 1-10 folder...

the below command is working fine....

for i in 1 3 5 7; do
find /A/B/C/${i} -name ".txt" -o -name ".csv" -o -name ".TXT" -o -name ".dat" |xargs ls -ltr |awk '{print $8 ,$9}' >> ${i}.txt
done

this will give me the result from the folder 1 3 5 7 ,from 1-10 which is inside A/B/C[/b] and print the file having the above extension into 1.txt , 3.txt , 5.txt , 7.txt etc inside /A/B/C

Help needed..

i need some help so that my syntax will search the file only from folder 1,3,5,7 from the 10 folder A/B/C and the out put from these 4 folder will be display in the single file i.e result.txt....not in different folder.

the above 1,3,5,7 folders are inside A/B/C

see also on other time...
http://www.unix.com/shell-programming-scripting/73107-can-you-please-help-me-out.html\#post302214206

You know, if you don't understand the response, or it is taking you in a direction that will not work for you, pose the question differently or something.

thats true..Could you please help me out on this...could you plse give me the solution for this...

for i in 1 3 5 7; do
find /A/B/C/${i} -name ".txt" -o -name ".csv" -o -name ".TXT" -o -name ".dat" |xargs ls -ltr |awk '{print $8 ,$9}' >> result.txt
done

it giving me result in result.txt as ...below..

1
3
5
7

i mean the folder name.. but if i am using ${i}.txt then its give me in separate file..not in a single file......

I have read all three posts and answers, but still do not understand what you have and/or what you want. Try a different approach to describe it.

/root
 /A
  /1.txt
  /3.dat
  /B
   /2.txt
   /C
    /1.txt
    /3.dat
    /5.TXT
 /AA
  /2.dat
  /3.dat
  /5.TXT
 /AAA
  /7.TXT

need a file containing...
>>>describe it here....

i mean let say the path is A/B/C...and inside C...i have 1-10 folder...

i need to find the different file type from different folder and to print those results in single out file..

for i in 1 3 5 7; do
find /A/B/C/${i} -name ".txt" -o -name ".csv" -o -name ".TXT" -o -name ".dat" |xargs ls -ltr |awk '{print $8 ,$9}' >> ${i}.txt
done

this give me output in 1.txt , 3.txt , 5.txt , 7.txt..

but i need the result in one file let say result.txt...if am putting result.txt in plase of ${i}.txt then i am getting result in result.txt as below

1
3
5
7

but here i need the file which contains in these folder 1,3,5,7 and print in result.txt....

or let say...

A/B/C/1 2 3 4 5 6 7 8 9 10...

i mean inside C i have 10 folder..
in 1- a.txt
in 2- b.txt
in 3- c.txt
in 4- d.txt
in 5- e.txt
in 6- f.txt
in 7- g.txt
in 8- h.txt

the syntax should give me the result in result.txt from 1,3,5,7 folder is...
a.txt
c.txt
e.txt
g.txt

... too fast :slight_smile:

for i in `ls {1,3,5,7}/*.{txt,TXT,dat,csv} 2>/dev/null`;do echo ${i#*/} >> results.txt;done

What is the output with?

for i in 1 3 5 7; do
  find /A/B/C/${i} -name "*.txt" -o -name "*.csv" -o -name "*.TXT" -o -name "*.dat" 
done

thanks danmero..Frank many thanks....

for i in `ls {1,3,5,7}/.{txt,TXT,dat,csv} 2>/dev/null`;do echo ${i#/} >> results.txt;done
--------------------------------------------------------------------------------

but it will not find from all the folder....

.. awk -F'/' '{print $NF}' ....

i didnt get this...