Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Search Forums:



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-03-2010
Registered User
 

Join Date: May 2008
Posts: 81
Thanks: 34
Thanked 0 Times in 0 Posts
extra space issue with awk


Code:
for diskname in $(lspv |awk '{print $1}')
do
lquerypv -h /dev/|awk '/'$diskname'/ { print ; exit }'
done

No output is returning from the loop.
I think awk put an extra space to the command - lquerypv -h /dev/
so that the command is executed as i.e. lquerypv -h /dev/ hdisk230 with a space between /dev/ and hdisk230.

Please advise how to remove an extra space in this case if my guess is correct.

Thank you
Sponsored Links
    #2  
Old 09-03-2010
bartus11's Avatar
Registered User
 

Join Date: Apr 2009
Posts: 2,654
Thanks: 3
Thanked 789 Times in 777 Posts
Do:
Code:
lspv |awk '{print "="$1"="}'

so you don't have to guess
Sponsored Links
    #3  
Old 09-03-2010
Registered User
 

Join Date: May 2008
Posts: 81
Thanks: 34
Thanked 0 Times in 0 Posts

Code:
lspv |awk '{print "="$1"="}'

returns the outputs with =

Code:
=hdisk0=
=hdisk1=
=hdisk113=
...


Code:
 lspv |awk '{print "/dev/"$1}'

gives me like this:

Code:
/dev/hdisk0
/dev/hdisk1
/dev/hdisk113
...

It looks good so far, but if I put in


Code:
for diskname in $(lspv |awk '{print "/dev/"$1}')
do
lquerypv -h |awk '/'$diskname'/ { print ; exit }'
done

I am getting errors:


Code:
 Syntax Error The source line is 1.
 The error context is
                //dev/hdisk0/ >>>  { <<< 
 awk: 0602-500 Quitting The source line is 1.
 Syntax Error The source line is 1.
 The error context is
                //dev/hdisk1/ >>>  { <<< 
 awk: 0602-500 Quitting The source line is 1.
 Syntax Error The source line is 1.
 The error context is
                //dev/hdisk113/ >>>  { <<< 
 awk: 0602-500 Quitting The source line is 1.

Please advise.

Thank you so much

Last edited by Scott; 09-03-2010 at 04:46 PM.. Reason: Code tags, please...
    #4  
Old 09-03-2010
bartus11's Avatar
Registered User
 

Join Date: Apr 2009
Posts: 2,654
Thanks: 3
Thanked 789 Times in 777 Posts
Try:
Code:
for diskname in $(lspv |awk '{print $1}')
do
lquerypv -h /dev/|awk -vx=$diskname '$0~x{ print ; exit }'
done

Sponsored Links
    #5  
Old 09-03-2010
Registered User
 

Join Date: May 2008
Posts: 81
Thanks: 34
Thanked 0 Times in 0 Posts
I tried:

Code:
for diskname in $(lspv |awk '{print $1}')
do
lquerypv -h /dev/|awk -vx=$diskname '$0~x{ print ; exit }'
done

but, no output is returned still.
Please advise.
Sponsored Links
    #6  
Old 09-03-2010
bartus11's Avatar
Registered User
 

Join Date: Apr 2009
Posts: 2,654
Thanks: 3
Thanked 789 Times in 777 Posts
Are you sure this command is giving proper output? (containing disk names?):

Code:
lquerypv -h /dev/

Sponsored Links
    #7  
Old 09-03-2010
Registered User
 

Join Date: May 2008
Posts: 81
Thanks: 34
Thanked 0 Times in 0 Posts
The command has to be:


Code:
lquerypv -h /dev/hdisk#

// please note no space on
Code:
/dev/hdisk#

hdisk# comes from
Code:
 '/'$diskname'/ { print ; exit }'

It looks to me that i.e.
Code:
 lquerypv -h /dev/ hdisk0

(please note a space) is executed.

Please advise.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Issue with disk space usage figaro UNIX Desktop for Dummies Questions & Answers 2 06-26-2010 03:39 AM
Issue with insufficient swap or memory space kavithakuttyk UNIX for Advanced & Expert Users 3 09-25-2009 01:02 PM
Issue available disk space while using xdd mrpogo07 Filesystems, Disks and Memory 3 09-23-2009 05:56 PM
Need help with space issue bbbngowc UNIX for Dummies Questions & Answers 1 09-22-2008 02:34 PM
Space issue with Directory siba.s.nayak UNIX for Dummies Questions & Answers 1 06-03-2008 07:14 AM



All times are GMT -4. The time now is 04:08 AM.