Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- im using the command below to merge file1 and file2 to get file3 :
- awk 'NR==FNR {a[$2]=$1; next} {$(NF+1) = a[$NF]} 1' file2 file1 > file3
- when i use this command inside bash script using expect im getting the file3 empty (the command is working manually).
- script :
- #!/bin/bash
- # Bash Menu Script Example
- outputMME="$( expect <<END
- spawn ssh atndn@x.x.x.x
- expect "Password: " { send "passwordr" }
- expect "# " { send "bashr" }
- expect "$ " { send "cd /tmp/DPE_CORE/home/atndn/eniq/r" }
- expect "$ " { send "awk 'NR==FNR{a[$2]=$1; next} {\$(NF+1) = a[$NF]} 1' file2 file1 > file3r" }
- END
- )"
- echo "$outputMME"
- 471808241 29164840 1 10001 156197396
- 471722917 21067410 1 31001 135961856
- 471941441 20774160 1 7001 180995072
- 471568655 29042630 1 15001 157502996
- 471524711 20716360 1 4001 180226817
- 471873918 29583520 1 2001 128567298
- 471568650 29042631 1 15002 157502910
- 610146 156197396
- 531101 135961856
- 704011 180226817
- 502216 128567298
- 707012 180995072
- 615246 157502996
- 685221 157502910
- 471808241 29164840 1 10001 156197396 610146
- 471722917 21067410 1 31001 135961856 531101
- 471941441 20774160 1 7001 180995072 707012
- 471568655 29042630 1 15001 157502996 615246
- 471524711 20716360 1 4001 180226817 704011
- 471873918 29583520 1 2001 128567298 502216
- 471568650 29042631 1 15002 157502910 685221
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement