Go Back   The UNIX and Linux Forums > Operating Systems > AIX
Search Forums:



AIX AIX is IBM's industry-leading UNIX operating system that meets the demands of applications that businesses rely upon in today's marketplace.

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 03-22-2006
Registered User
 

Join Date: Nov 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Trouble formatting egrep command with AWK

Hi,
I'm new to scripting and AIX. I'm running the following:

lspv | awk '{ print "lspv",$1" | egrep 'PP\|PHYSICAL'; lspv -l",$1 }'

Which creates this command:

lspv hdisk0 | egrep PP|PHYSICAL; lspv -l hdisk0
lspv hdisk1 | egrep PP|PHYSICAL; lspv -l hdisk1

Troube is, I need the patterns for egrep to be enclosed in single quotes
lspv hdisk0 | egrep 'PP|PHYSICAL'; lspv -l hdisk0
lspv hdisk1 | egrep 'PP|PHYSICAL'; lspv -l hdisk1

I thought using backslashes would help:
lspv | awk '{ print "lspv",$1" | egrep \'PP\|PHYSICAL\'; lspv -l",$1 }'

but get the same results:
lspv hdisk0 | egrep PP|PHYSICAL; lspv -l hdisk0
lspv hdisk1 | egrep PP|PHYSICAL; lspv -l hdisk1

I've entered the command manualy to get the desired results, below:

root@test:/ > lspv hdisk1 | egrep 'PP|PHYSICAL'; lspv -l hdisk1
PHYSICAL VOLUME: hdisk1 VOLUME GROUP: sanvg
PP SIZE: 16 megabyte(s) LOGICAL VOLUMES: 5
TOTAL PPs: 955 (15280 megabytes) VG DESCRIPTORS: 2
FREE PPs: 534 (8544 megabytes) HOT SPARE: no
USED PPs: 421 (6736 megabytes) MAX REQUEST: 256 kilobytes
hdisk1:
LV NAME LPs PPs DISTRIBUTION MOUNT POINT
sas 52 52 00..52..00..00..00 /sas
worktest 326 326 07..128..191..00..00 /worktest
db2data1 32 32 32..00..00..00..00 /db2data1
loglv00 1 1 00..01..00..00..00 N/A
scripts 10 10 00..10..00..00..00 /scripts


Any ideas?
Sponsored Links
    #2  
Old 03-22-2006
vgersh99's Avatar
ɹoʇɐɹǝpoɯ
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 6,959
Thanks: 69
Thanked 351 Times in 338 Posts

Code:
lspv | awk -v q="'" '{ print "lspv",$1" | egrep " q "PP\|PHYSICAL" q "; lspv -l",$1 }'

Sponsored Links
    #3  
Old 03-22-2006
Registered User
 

Join Date: Nov 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Thanks, vgersh99!
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
Egrep cheat sheet anywhere? Looking for meaning of egrep -c leelm UNIX for Dummies Questions & Answers 2 01-11-2008 02:37 PM
Formatting Substitution Command Not Working in vi ERPKEN UNIX for Advanced & Expert Users 11 05-06-2007 09:36 PM
egrep command annelisa Shell Programming and Scripting 4 07-05-2006 04:33 AM
is running this command via ssh possible? (formatting issues) LordJezo Shell Programming and Scripting 1 08-19-2005 08:40 AM
trouble using mailx command ldrojasm Shell Programming and Scripting 2 04-03-2002 05:52 AM



All times are GMT -4. The time now is 10:49 PM.