Variable I have in my shell script
diff=$1$2.diff
id=$2
new=new_$diff
echo "My id is $1"
echo "I want to sync for user account $id"
##awk command I am using is as below
cat $diff | awk -F'~' ''$2 == "$id"' {print $0}' > $new
I could see value of $id is not passing to the awk command, i also tried few options as below but no help. Please assist.
#awk -F'~' -v search=$id '$2 == "search" {print $0} file' nayaka2almadm1.diff > $new
#cat $diff | awk -v "search=$id" -F'~' '$2 == "search" {print $0}' > $new
#cat $diff | awk -F'~' -v search="$id" '$2 ~ "^\"search {print $0}' > $new
#awk -v search="$id" file="$diff" | awk -F'~' '$2 == search {print $0} file' > $new
If I am passing the value directly in place of $id then it is working.
Thanks in advance.
Regards,
Ashutosh