Reputation: 51
I declare a temporary file
TEMPFILE="$(mktemp)"
Then I have an awk statement fill it with an output... Next step, I have another AWK statement take out particular field to put into an array... this is 'crapping out'
DATES = ($(awk -F'/' '{print $2}' '${TEMPFILE}'))
I'm also parsing out into a separate array using a CUT (not sure if it's working either)
IPS = ($(cut -f2 $(TEMPFILE)))
I'm getting the error:
Script12.sh: line 36: syntax error near unexpected token `('
Script12.sh: line 36: `DATES = ($(awk -F'/' '{print $2}' '${TEMPFILE}'))'*
Upvotes: 0
Views: 453
Reputation: 5787
Don't use blanks for variable assignment in BASH. There should be no blanks around the =
sign
Upvotes: 3
Reputation: 72717
The shell is space-sensitive. The shell syntax for assignment is
var1=[word1] ...
where the [] indicates an optional part, and ... repetition.
Note: no blanks around the =
sign.
Then, there is no parameter expansion (replacing $var
with its value) inside single quotes. Use double quotes:
DATES=($(awk -F/ '{print $2}' "${TEMPFILE}"))
Upvotes: 3
Reputation: 204229
You can't put spaces around assignments in shell and you need to change single to double quotes around your shell variable when used in your awk command line, i.e. "$TEMPFILE"
not '${TEMPFILE}'
and then not try to execute that variable on your cut command line (think about what $(TEMPFILE)
means).
Upvotes: 2