parsing output from ls command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting parsing output from ls command
# 1  
Old 05-10-2006
parsing output from ls command

I have to test the directory name which is obtained from

for dir in `ls -l|grep $9 '
i need to check whether it is directory ( [ -d dir ]

if yes, I have to check the first 3 character fo the directory

how can I do that? Please help me

thanks
# 2  
Old 05-10-2006
Quote:
I have to test the directory name which is obtained from

for dir in `ls -l|grep $9 '
i need to check whether it is directory ( [ -d dir ]

if yes, I have to check the first 3 character fo the directory

how can I do that? Please help me

thanks
your statement is not clear !!!
to list dirs ls -l | grep ^d

what abt this ?
Quote:
if yes, I have to check the first 3 character fo the directory
Can you please be some more specific?
If possible with an example.
# 3  
Old 05-10-2006
firt I have to find the directory in a directory

ls -ld */ will do it

once I find it is directory, I have to check the first 3 character of the directory

drwxr-xr-x 2 mqm mqm 512 Jan 20 09:36 DQAT001/
drwxr-xr-x 3 mqm mqm 512 Jan 25 12:38 DQAT004/
drwxr-xr-x 2 mqm mqm 512 Apr 20 07:55 DQAT0040/
drwxr-xr-x 2 mqm mqm 512 Apr 20 10:31 DQAT0041/
drwxr-xr-x 2 mqm mqm 512 Jul 13 2005 DQAT005/
drwxr-xr-x 2 mqm mqm 512 May 2 09:33 DQBT007/

in the above I have to find certain directory which has first three character say ' DQA'

how i can check the first three character in the "DQAT001/"

i hope you understand
thanks
# 4  
Old 05-10-2006
more clearly I am trying to like this


for i in ` ls -ld */ |awk '{print $9}'| awk -F \/ '{print $1}'` ;
do

awk $i~/^DQA/ ' {
log for processing goes here

}'
done

when i find directoy, then i need to see first three character of $i and if matches, process

thanks
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing of TOP output

Hi , i am trying to set up an alert, when CPU usage (0.2%us in below output) is more than 40% top | head | grep '^Cpu' Cpu(s): 0.2%us, 0.2%sy, 0.0%ni, 99.1%id, 0.6%wa, 0.0%hi, 0.0%si, 0.0%st using CUT, i pulled the value 0.2 and assigned to CPU (variable) CPU=$(expr `top | head -10... (5 Replies)
Discussion started by: Prateek007
5 Replies

2. Shell Programming and Scripting

Parsing fields from class list files to use output with newusers command

Hello I am trying to develop a shell script that takes a text file such as this... E-mail@ Soc.Sec.No. *--------Name-----------* Class *School.Curriculum.Major.* Campus.Phone JCC2380 XXX-XX-XXXX CAREY, JULIE C JR-II BISS CPSC BS INFO TECH 412/779-9445 JAC1936 XXX-XX-XXXX... (7 Replies)
Discussion started by: crimputt
7 Replies

3. Shell Programming and Scripting

parsing output

Can somebody provide a solution to parse the following; cat /tmp/xxx Name: QUE_REQU (o.mtaseast-o.dmart) (MTPost queue) Number of messages: 66446 (Age 686 min; Size 214 mb) Backlog (messages): 0 (Age 0 min) Name: QUE_REQU... (6 Replies)
Discussion started by: BeefStu
6 Replies

4. Shell Programming and Scripting

Parsing the date output

Hi fellows, I need to define a notification for SSL certificate expiration. My Command output is below: (this is the "Expiration Date") Tue Mar 15 09:30:01 2012 So, at 15th Feb (1 month before the expiration), a notification has to be triggered by a script or sth else. How can i set an... (5 Replies)
Discussion started by: oduth
5 Replies

5. Shell Programming and Scripting

parsing ifconfig output

I'm trying to gather information on the interfaces on a large number of servers. If I run ifconfig I will get: eth0 Link encap:Ethernet HWaddr 00:50:56:A2:27:C1 inet addr:10.145.xxx.xxx Bcast:10.152.45.255 Mask:255.255.254.0 ----- eth1 Link... (2 Replies)
Discussion started by: C0ppert0p
2 Replies

6. Shell Programming and Scripting

Parsing dynamic data from a command output

Hi people, I am writing a korn shell script, and one of the command gives an output something like below: release.label.2010.03.02 objects: /project/path/to/some/file_name.ksh /project/path/another/file_name01.dat I have to retrieve the file paths one by one & use them as... (9 Replies)
Discussion started by: kiwin1000
9 Replies

7. Shell Programming and Scripting

parsing output of system()

Hi, From the above output of df command I need to parse only 43G (available space) and display it. root@localhost:> df -h /vol1/joy Filesystem Size Used Avail Capacity Mounted on /vol1/joy 180G 137G 43G 76% ... (3 Replies)
Discussion started by: cjjoy
3 Replies

8. Shell Programming and Scripting

Parsing output

I need to parse the following out put and determine if the USB is a DISK and whether or not it's External. If an HBA line contains "USB" then does the next line contain "DISK" and "External". 0:0,31,0: HBA : (aacraid,1) AAC SCSI 0,0,0: DISK : Adaptec ASR4800SAS Volu0001 ... (6 Replies)
Discussion started by: lochraven
6 Replies

9. Shell Programming and Scripting

parsing output

I have a file that contains the output of the ls -iR command, something like this: ./results: 2504641011 result_1410 2500957642 result_525 2504641012 result_1425 2500957643 result_540 ./tests/1: 2500788755 1 2500788743 1000 ./tests/2: 2500788759 3 2500788758 999 ... (6 Replies)
Discussion started by: looza
6 Replies

10. Shell Programming and Scripting

parsing output from a diff command...

hi, i have a script which pipes the output of a diff -rq command into a separate file/ it would read something like this: Files mod1/lala/xml/test1.txt and mod2/lala/xml/test1.txt differ Only in mod2/lala/xml: test2.txt What i need to do is to parse this file so i end up with just a... (5 Replies)
Discussion started by: kam
5 Replies
Login or Register to Ask a Question