Reputation: 7451
I'm having difficulty getting the awk command inside a bash script to work. The script follows:
#!/bin/bash
fpga-test -1 -a $1 > tmp.file && awk \'\/Read\/ {print \$2}\' tmp.file
When I run the command I get the following error.
# my_script 14
awk: cmd. line:1: Unexpected token
The intermediate file (tmp.file) looks like this, and I want only the second tokenized string.
Read 32769 or -32767 (0x8001) @ 0x0e
Suggestions?
Upvotes: 0
Views: 2028
Reputation: 7638
Turing:~ vince$ cat ex.txt
Read 32769 or -32767 (0x8001) @ 0x0e
Read 32769 or -32767 (0x8001) @ 0x0e
Read 32769 or -32767 (0x8001) @ 0x0e
Turing:~ vince$ awk '/Read/ {print $2}' ex.txt
32769
32769
32769
Is that what you want?
Upvotes: 1
Reputation: 41465
There is a problem with your escaping. Also, there is no need for a temporary file in this case.
#!/bin/bash
fpga-test -1 -a $1 | awk '/Read/ {print $2}'
Upvotes: 4