Hi,
I am trying to write a bash script in which I need to pass a external variable to the awk program. I tired using -v but it not accepting the value.
Here is my sample code.
#!/usr/bin/bash
######################################################################################
#### This bash script is to form meta
#### To run the script we have to do in the following format ./meta_script.sh frame_no lun_id's no_of_way_meta
### If you want to create 8 way meta for devics 18DF:18FE on frame 5643 EG: ./meta_script.sh 5643 18DF:18FE 8
ARGS=3
E_WRONGARGS=85
if [ $# -ne "$ARGS" ] # Check for proper number of command-line args.
then
echo "Usage: `basename $0` frame_no lund_id NO_of_WaY_meta "
exit $E_WRONGARGS
fi
frame_no=$1;
lun_id=$2
meta_way=$3;
echo "$frame_no, $lun_id, $meta_way "
#if [ $frame_no -ne "\[0-9\]*" ]
#then
#echo " please enter frame no EG: 1234 "
#exit $E_WRONGARGS
#fi
#if [ $lun_id != "[0-9A-F]*:[0-9A-F]*" ]
#then
# echo " please enter device in 18DF:18FE format "
# exit $E_WRONGARGS
#fi
#symaccess -sid $frame_no list assign -devs ${lun_id}|awk '/^[0-9]/ {print $1}'|nawk -v m=$meta_way 'NR%m==1{print " this is the value m";val=$0;print "form meta from dev "$0" config=striped;";next;}{print "add dev "$0" to meta "val";"}' >meta
symaccess -sid $frame_no list assign -devs ${lun_id}|awk '/^[0-9]/ {print $1}'
cat meta |awk '$5~/^[0-9]/ {print "bind tdev "$5" to pool VP_TIER_SATA,preallocate size=aaaa cyl;";}'> binding
cat binding |awk '{print $3}'|xargs|sed 's/ /,/g'
#
In the above code I am trying to pass the variable 8 which is $meta_way to the awk program but it is not accepting. Let me know if I am doing anything wrong.
Any help is greatly appreciated. Thanks in advance.