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
parsing output from SQL querry ludvig Shell Programming and Scripting 7 10-23-2007 05:42 AM
parsing output from a diff command... kam Shell Programming and Scripting 5 05-29-2007 11:26 PM
problem parsing output file ragha81 Shell Programming and Scripting 13 03-21-2007 02:06 PM
problem parsing process-output victorin Shell Programming and Scripting 3 07-25-2006 05:31 AM
HTTP Query Request & Parsing returned XML output jerardfjay Shell Programming and Scripting 15 05-18-2005 09:25 AM

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 05-10-2006
ajaya ajaya is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 28
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 (permalink)  
Old 05-10-2006
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
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 (permalink)  
Old 05-10-2006
ajaya ajaya is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 28
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 (permalink)  
Old 05-10-2006
ajaya ajaya is offline
Registered User
  
 

Join Date: Mar 2006
Posts: 28
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
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 11:17 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