I am new to grep and awk - using Windows 7 (I downloaded grep and awk for windows from GnuWin).
I am have having trouble running this script:
grep -Fwf dictionary.txt frequency.txt | awk '{print $2 "," $1}'
I get the error:
awk: '{print
awk: ^ invalid char ''' in expression
I believe it might have something to do with having to use double quotes in Windows, but I tried all the combinations I can think of and still it doesn't work.
Can anyone help? Thanks
On Windows, you need to use double quotes to quote your awk commands. So
grep -Fwf dictionary.txt frequency.txt | awk '{print $2 "," $1}'
needs to be changed to
grep -Fwf dictionary.txt frequency.txt | awk "{print $2 "," $1}"
But remember, you can't use double quotes inside double quotes, you need to escape them. On Windows you can't simply use \ to escape it. You need the following syntax:
grep -Fwf dictionary.txt frequency.txt | awk "{print $2 \"",\"" $1}"
Right, that's \"" to represent " inside double quotes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With