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


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need some help...can any body give some idea
# 1  
Old 02-23-2008
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 x.txt).

am using the syntax:
ls -l *.txt| awk '{print $8 , $9} >x.txt

which giveing me the result for one sub folder

that syntax is working fine if i am checking it in a single folder..
but the i want a script that will run and it will check in all subfolder for todays file and give the results in a single out put file.(i mean in output file it will print the time and the file name from all sub folder)



-rwxrwxrwx 1 ADMIN None 73 Jan 13 19:36 1.txt

out put:
19:36 1.txt.
# 2  
Old 02-23-2008
if you use ls with -R option it lists stuff in all subfolders too
# 3  
Old 02-23-2008
need some help...can any body give some idea

thanks for the reply..

thats true but how it will recognise all the files from all folder andgive me the result...

if i am giving the below syntax from one sub folder its giving me the result from that sub folder.

ls -l *.txt| awk '{print $8 , $9} >x.txt

what i need to do is from main folder i want do somthing so that it will give me the results from all sub folder one at a time...
# 4  
Old 02-23-2008
maybe use the find command?

Code:
find XYZ -type f -name '*.txt' | xargs ls -l | awk '{print $8 , $9}'

this will find all files .txt under directory XYZ, ls -l for each of these, and then get the 8th and 9th column that you wanted
# 5  
Old 02-23-2008
need some help..can any body give me some idea..

thanks for the reply..

thats true but how it will recognise all the files from all folder andgive me the result...

if i am giving the below syntax from one sub folder its giving me the result from that sub folder.

ls -l *.txt| awk '{print $8 , $9} >x.txt

what i need to do is from main folder i want do somthing so that it will give me the results from all sub folder one at a time...

1.main folder XYZ
2.sub folder abc , def , mno
3.under abc-1.txt,2.txt
under def-3.txt,4.txt
under mno-5.txt,6.txt
want to put some syntax from xyz folder so that in out put file 1.txt i will get all this subfolder files..

if i am giving:

ls -l *.txt| awk '{print $8 , $9} >x.txt

from abc sub folder its giving only resuls from abc..

like that i need all files name in out put file one at a time..i need a script so that it will run and give me the out put for that.
# 6  
Old 02-23-2008
need some help..can any body give me some idea..

many thanks again James..

i will check it...thanks for giving me the solution..
# 7  
Old 02-23-2008
need some help..can any body give me some idea..

james am getting some problem in my server..

question..

if i will use that syntax..will it give me the all files from all the subfolder in a single output file having .txt extension..
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk idea

Hello everybody, I am new here as well as in scripting. I need some help. I have log files that are boring to examine. I wanted to use awk to do this: -get the lines that match the eight field (user mac address) -now sort them according to date (first 2 fields) -print the following: ... (4 Replies)
Discussion started by: anaABB
4 Replies

2. Programming

Would you please give me some idea about single client and multiple servers

Hi, I have a program which needs to connect multiple servers at the same time. The program has to collect data from each of servers and then make a decision regarding to the data received. There are several requirements. 1. Server (s) may shutdown anytime without any ack (e.g.power... (1 Reply)
Discussion started by: sehang
1 Replies

3. Shell Programming and Scripting

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"... (9 Replies)
Discussion started by: sapan123
9 Replies

4. Shell Programming and Scripting

help... no idea what to use

my issue now is i have a txt file containing a list like below i want to create a script that will add a constant text "Find this name" at the start and "at your directory" at the end. every line should be added by phrase at the start and end. Each line of the file should look like "Find... (4 Replies)
Discussion started by: dakid
4 Replies

5. 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

6. Shell Programming and Scripting

Here is an interesting idea...

Does anyone know how to test if an ethernet interface is alive, or accepting connections? Here is the scenario - I have rsc and sc console interfaces on some Suns. There are some sporadic vulnerability scans that send them out to lunch when they run the scans. I have to login to the host and reset... (0 Replies)
Discussion started by: lm_admin_dh
0 Replies

7. Shell Programming and Scripting

any good idea on this?

txt file like this, 1 2 3 4456 a bb c d 3 f e 1 k 32 d m f e 123 m 2 k every line contains 3 or more columns, all the columns are separated by space, and every column includes 1 to 3 character. what I wanna do is deleting the first three columns, and keep the rest no matter how long... (7 Replies)
Discussion started by: fedora
7 Replies

8. Shell Programming and Scripting

Limitations of awk? Good idea? Bad idea?

Keeping in mind that I'm relatively comfortable with programming in general but very new to unix and korn/bourne shell scripts.. I'm using awk on a CSV file, and then performing calculations and operations on specific fields within specific records. The CSV file I'm working with has about 600... (2 Replies)
Discussion started by: yongho
2 Replies
Login or Register to Ask a Question