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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Can any body give me a solution to this...
# 1  
Old 07-15-2008
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
# 2  
Old 07-15-2008
Data third time seeing this exact question....

see also on other time...
https://www.unix.com/shell-programmin...#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.
# 3  
Old 07-15-2008
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......
# 4  
Old 07-15-2008
Tools Perhaps you are not getting a 'good' answer because of the way you describe it

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.
Code:
/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....
# 5  
Old 07-15-2008
plz

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....
# 6  
Old 07-15-2008
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
# 7  
Old 07-15-2008
... too fast Smilie
Code:
for i in `ls {1,3,5,7}/*.{txt,TXT,dat,csv} 2>/dev/null`;do echo ${i#*/} >> results.txt;done


Last edited by danmero; 07-15-2008 at 04:27 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

6 More Discussions You Might Find Interesting

1. What is on Your Mind?

How to encourage emerging users in forum to give better solution:?

Our moderators/admins/users are doing great job by sharing knowledge with each other, they do correct/appreciate us in posts. This poll is to encourage emerging users to go in a better direction, kindly do give your thoughts on same. 1- Giving them a reward/appreciation if they are... (31 Replies)
Discussion started by: RavinderSingh13
31 Replies

2. Shell Programming and Scripting

Mail with body

Hello All, I wish to mail after completion of code. I would like to include subject and body in it. I am not looking to read the body from other file but willing to provide the body in the command itself. Can i do this way? I am looking to pass some parameters to body and this will be possible... (1 Reply)
Discussion started by: forums123456
1 Replies

3. UNIX for Dummies Questions & Answers

can any body help me out on 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"... (2 Replies)
Discussion started by: sapan123
2 Replies

4. Linux

Can any body tell me.

:(I want to install linux (SLES-9-SP4-CD-x86_64-GM-CD1) but it doesnot work. It said the computer is 32 bits you cannot use 64 bits on it. (3 Replies)
Discussion started by: sackNumchai
3 Replies

5. Shell Programming and Scripting

need some help...can any body give some idea

Hi i need some help... 1.i have one main folder XYZ. 2.Many folders inside xyz say abc,def,mno 3.And inside each folder, i have many files . want to print what ever files are present inside the subfolder abc,def,mno (what ever todays file ) in output file.out put file should be in xyz(say... (13 Replies)
Discussion started by: sapan123
13 Replies

6. UNIX for Advanced & Expert Users

can any body give some idea on this..

create one script That reads a file <file> Each line of <file> file contains just an account The run the grep command like below /usr/xpg4/bin/grep -E -e 'ACCOUNT.*' < File> > <OUTPUT FILE> (1 Reply)
Discussion started by: sapan123
1 Replies
Login or Register to Ask a Question