Visit Our UNIX and Linux User Community


need script to process ls-l command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting need script to process ls-l command
# 1  
Old 04-09-2004
need script to process ls-l command

ne1 know how i can do this????

a script that process the output of UNIX command ls -l

cheers
# 2  
Old 04-09-2004
How do you desire to process it?
# 3  
Old 04-09-2004
do u think it would be best to process the list into a file

i.e. ls-l>sinner (sinner name of file)

but if i do this how can i add it into a script

im guessin but will it be somethin like this

#!/usr/bin/csh
#send list to file
code..................................
#read file
code....................................
# 4  
Old 04-09-2004
sinner your missing the point of Tuxs response.

what are you trying to do w/ the ls -l output?
what are your program requirements?
what is your final goal for this project?
# 5  
Old 04-10-2004

well i need a script that process the output of UNIX command ls -l, where the script takes, the long listing and reduces it to print the size, name of the file, total number of bytes and number of ordinary-files listed.

Last edited by sinner; 04-10-2004 at 04:45 AM..
# 6  
Old 04-10-2004
Using awk,

ls -l | awk '{print $1, $2, $3, $4}'

where $1, $2 , $3 are the fields that you wish to print. Awk will delimit each field in the listing of "ls -l" by a space. Each successive field can be printed by providing the field number. So print $1, $2, $3, $4 will print out the first 4 fields. Change the field values to correspond to the field positions you want printed.

On second thought, this seems too much like homework. If it is, you have enough to go on to figure out the rest Smilie

Last edited by google; 04-10-2004 at 09:29 AM..
# 7  
Old 04-10-2004
cheers bro owe u 1

Previous Thread | Next Thread
Test Your Knowledge in Computers #275
Difficulty: Easy
OpenSolaris is the only version of the System V variant of UNIX available as open source.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Command to get exact tomcat process I am running ignoring other java process

Team, I have multiple batchjobs running in VM, if I do ps -ef |grep java or tomcat I am getting multiple process list. How do I get my exact tomcat process running and that is unique? via shell script? (4 Replies)
Discussion started by: Ghanshyam Ratho
4 Replies

2. AIX

Command or script to inform server owner about process

Hi all, How to inform server owner if the particular process is down. I need command or script to do the above. TIA (3 Replies)
Discussion started by: sumanthupar
3 Replies

3. Shell Programming and Scripting

script to get child process for a process

!/bin/sh pid=$(ps -Aj | grep MSTRSvr | grep -v grep | awk '{print $1}') sid=$(ps -Aj | grep MSTRSvr | grep -v grep | awk '{print $3}') ps -s "$sid" I am not able to get the desired output it says process list error if i use watch ps -s "$sid" it considers only the first session id (5 Replies)
Discussion started by: schippada
5 Replies

4. Shell Programming and Scripting

script to monitor the process system when a process from user takes longer than 15 min run.

get email notification from from system when a process from XXXX user takes longer than 15 min run.Let me know the time estimation for the same. hi ,any one please tell me , how to write a script to get email notification from system when a process from as mentioned above a xxxx user takes... (1 Reply)
Discussion started by: kirankrishna3
1 Replies

5. UNIX for Dummies Questions & Answers

Script to start background process and then kill process

What I need to learn is how to use a script that launches background processes, and then kills those processes as needed. The script successfully launches the script. But how do I check to see if the job exists before I kill it? I know my problem is mostly failure to understand parameter... (4 Replies)
Discussion started by: holocene
4 Replies

6. Shell Programming and Scripting

Process diff command output in a shell script

diff -yta file1 file2 #!/usr/abc/b/bin/perl5.6 | #!/usr/abc/b/bin/perl5.8 Notable thing about above line is "|" appears at 62nd position. When the same line is assigned in a variable in a ksh script, using ss=$(diff -yta file1 file2) it appears as ... (4 Replies)
Discussion started by: bhaliyajalpesh
4 Replies

7. Shell Programming and Scripting

Shell Script to Kill Process(number of process) Unix/Solaris

Hi Experts, we do have a shell script for Unix Solaris, which will kill all the process manullay, it used to work in my previous env, but now it is throwing this error.. could some one please help me to resolve it This is how we execute the script (and this is the requirement) ... (2 Replies)
Discussion started by: jonnyvic
2 Replies

8. Shell Programming and Scripting

Perl script to kill the process ID of a command after a certain period

All, I am trying to build a script in perl that will alllow me to pass the IP address to a ping command and redirect the output to a file and then kill that process after a certain period of time. let's say, I call my script ping.pl, I would like to be able to run it like this for example :... (7 Replies)
Discussion started by: Pouchie1
7 Replies

9. Shell Programming and Scripting

script to monitor process running on server and posting a mail if any process is dead

Hello all, I would be happy if any one could help me with a shell script that would determine all the processes running on a Unix server and post a mail if any of the process is not running or aborted. Thanks in advance Regards, pradeep kulkarni. :mad: (13 Replies)
Discussion started by: pradeepmacha
13 Replies

10. Shell Programming and Scripting

Script - How to automatically start another process when the previous process ends?

Hi all, I'm doing automation task for my team and I just started to learn unix scripting so please shed some light on how to do this: 1) I have 2 sets of datafiles - datafile A and B. These datafiles must be loaded subsequently and cannot be loaded concurrently. 2) So I loaded datafile A... (10 Replies)
Discussion started by: luna_soleil
10 Replies

Featured Tech Videos