0

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?

2 Answers 2

4

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}'
Sign up to request clarification or add additional context in comments.

Comments

1
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?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.