tags:

views:

364

answers:

2

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?

+3  A: 

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}'
Juliano
That was quick, and thanks.
Jamie
A: 
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?

Vince