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.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Can any body tell me. sackNumchai Linux 3 05-06-2008 12:28 AM
need some help...can any body give some idea sapan123 Shell Programming and Scripting 13 02-23-2008 03:19 PM
can any body give some idea on this.. sapan123 UNIX for Advanced & Expert Users 1 10-21-2007 12:10 PM
can any body correct the code vivekanandarpat UNIX for Advanced & Expert Users 2 09-16-2005 09:24 AM
Can any body correct the code vivekanandarpat Shell Programming and Scripting 6 09-15-2005 02:16 PM

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

Join Date: Oct 2007
Posts: 39
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 (permalink)  
Old 07-15-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Unhappy third time seeing this exact question....

see also on other time...
can you please help me out on this...

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 (permalink)  
Old 07-15-2008
sapan123 sapan123 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 39
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 (permalink)  
Old 07-15-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Cool 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 (permalink)  
Old 07-15-2008
sapan123 sapan123 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 39
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 (permalink)  
Old 07-15-2008
sapan123 sapan123 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 39
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 (permalink)  
Old 07-15-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,294
What is the output with?

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" 
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:19 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