param with awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting param with awk
# 1  
Old 03-28-2008
param with awk

Hi All,

I have this script:

#!/bin/ksh
lsvg -l $1|grep -v $1:|grep -v LV|awk '{print "mklvcopy ",$1," 2 $2 $3"}'

I want to pass three param with "vg2 hdisk1 hdisk2" but the output is "mklvcopy lv1 2 $2 $3". I want to pass the hdisk1 and hdisk2 and not the $2 and $3.

Please help!

Thanks in advance,
itik
# 2  
Old 03-28-2008
try this:
Code:
lsvg -l $1|grep -v $1:|grep -v LV|awk -vp1=$1 -vp2=$2 -vp3=$3 '{print "mklvcopy "p1" 2 "p2" "p3}'

# 3  
Old 03-28-2008
Might as well fix those dreadful Useless Uses of Grep | Awk.

Code:
lsvg -l "$1"| awk -vp1="$1" -vp2="$2" -vp3="$3" '!/LV|'"$1"'/{print "mklvcopy "p1" 2 "p2" "p3}'


Last edited by era; 03-28-2008 at 04:00 PM.. Reason: As long as we are discussing style, properly quote everything
# 4  
Old 03-28-2008
Actually, here's the correct one:

lsvg -l $1|grep -v $1:|grep -v LV|awk -vp2=$2 -vp3=$3 '{print "mklvcopy "$1" 2 "p2" "p3}'

If I use the above code, it will give me the vg parameter and not the lv.



Cool! Thank you guys.

Last edited by itik; 05-07-2008 at 12:18 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Dynamics param for script

Hi everyone, I need a way to take the value of a parameter with a for lood. For example i execute the script with this parameter ./Script PARAM1 PARAM2 PARAM3 PRAM4 for i in <LIST OF PARAMETERS> do PARAMETERS=$<NUMBER OF PARAMETER> done How can i express <LIST OF... (1 Reply)
Discussion started by: Xedrox
1 Replies

2. Shell Programming and Scripting

check for param values

I need to check for 4ht parameter values, if they are not in (17,18) in other words if they r not equal to 17 or 18 then exit. can u help pls (4 Replies)
Discussion started by: raopatwari
4 Replies

3. UNIX for Dummies Questions & Answers

sqlplus script out param

For starters, I have read the forums from top to bottom and cannot find a solution to this particular scenario. Just finished up two hours or scouring the archives. Here is my question which has been asked numerous times before but never fully explained for this particular solution: How do I pass a... (2 Replies)
Discussion started by: jwil0m0
2 Replies

4. Shell Programming and Scripting

param as current date+time

Hi All, I need to pass param on aix "errpt -a -s MMDDHHMMYY -e MMDDHHMMYY". How do I read the date+time on the system and pass it as parameter? I need also the -s as previous day and the -e as current day. Thanks, itik (1 Reply)
Discussion started by: itik
1 Replies

5. AIX

errpt with param for yesterday and today

Hi All, I would like to create a script with "errpt" that will read the date yesterday and today and execute this: "errpt -a -s yesterdaydatetime -e todaydatetime". For example: >errpt -a -s 0604000008 -s 0605235908 Note: Time is fixed with start "0000" and end "2359". So... (0 Replies)
Discussion started by: itik
0 Replies

6. UNIX for Advanced & Expert Users

param with awk

Hi All, I have this script: #!/bin/ksh lsvg -l $1|grep -v $1:|grep -v LV|awk '{print "mklvcopy ",$1," 2 $2 $3"}' I want to pass three param with "vg2 hdisk1 hdisk2" but the output is "mklvcopy lv1 2 $2 $3". I want to pass the hdisk1 and hdisk2 and not the $2 and $3. Please help! ... (1 Reply)
Discussion started by: itik
1 Replies

7. Shell Programming and Scripting

need help on korn passing param

Hi, I need to script this: lsvg -l vg10|grep -v vg10:|grep -v LV|awk '{print "chlv -u 2 ",$1}' > script_vg10.sh So that I could just pass the parameter of the volume group. When I did this on a script: #!/bin/ksh lsvg -l %1|grep -v %1:|grep -v LV|awk '{print "chlv -u 2",$1}' >... (4 Replies)
Discussion started by: itik
4 Replies

8. HP-UX

kernel param listings

Which shows the current kernel settings accurately? kmtune or sysdef. I ask because although some params show the same setting with both, some do not. Example >kmtune | grep nfile nfile 75008 - (15*NPROC+2048) >sysdef | grep nfile nfile 75018 ... (6 Replies)
Discussion started by: theninja
6 Replies

9. HP-UX

find command using -mmin param

Hi Everyone, I would like to know how to find a file which was created in the period of 20+ hours, in most common unix OS, the parameter -mmin is not supported (i.e, HP-UX, Solaris, LInux, AIX) Could you help on this ?? (3 Replies)
Discussion started by: jmbeltran
3 Replies

10. UNIX for Dummies Questions & Answers

capturing oracle procedure out param value

I have a procedure with an out parameter, I want to use this value in a shell script, I've done this in perl before but they want this to be a ksh script. what is the syntax to do this. this was my first thought; #!/usr/bin/ksh sqlplus -s scott/tiger@db << EOF ... (1 Reply)
Discussion started by: edog
1 Replies
Login or Register to Ask a Question