The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-12-2008
sapan123 sapan123 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 39
can you please 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....

find /A/B/C -name "*.txt" -o -name "*.csv" -o -name "*.TXT" -o -name "*.dat" |xargs ls -ltr |awk '{print $8 ,$9}' > result.txt

this will give me the result from the folder 1-10 which is inside A/B/C and print the file having the above extension into result.txt...


Help needed..

i need the syntax so that my syntax will search the file only from folder 1,3,5,7 and the out put from these 4 folder will be display in the single file i.e result.txt....

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

Thanks in advance....
  #2 (permalink)  
Old 07-12-2008
mirusnet's Avatar
mirusnet mirusnet is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 146
Maybe something like this:
Code:
 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
  #3 (permalink)  
Old 07-12-2008
sapan123 sapan123 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 39
Thanks alot man..

can you give me some more idea....syntax
  #4 (permalink)  
Old 07-12-2008
sapan123 sapan123 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 39
Friend one more thing...

As you mentioned
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

so the out put file will be ???????
  #5 (permalink)  
Old 07-12-2008
mirusnet's Avatar
mirusnet mirusnet is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 146
Code:
${i}.txt
for each dir.

Code:
1.txt 3.txt 5.txt 7.txt
  #6 (permalink)  
Old 07-12-2008
sapan123 sapan123 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 39
thanks for the reply again..

but i need all these result in a sigle out file....

i mean let say result.txt will be the out file.....

and it should contain the results from 1 3 5 7 etc...
  #7 (permalink)  
Old 07-12-2008
mirusnet's Avatar
mirusnet mirusnet is offline
Registered User
  
 

Join Date: Dec 2007
Posts: 146
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
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 04:07 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0