Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
gawk '{print $1|"sort"}' somfile

This will do in cygwin bash, but in cmd.exe, it failed. My gawk's version info:

C:\Documents and Settings\Administrator>gawk --version

GNU Awk 3.1.5

share|improve this question

1 Answer 1

Perhaps because in cmd.exe you have to use double-quotes (") not apostrophe (') to delimit parameters.

  gawk "{print $1|\"sort\"}" somefile

(untested)

share|improve this answer
    
Close ;). You need the outer double quotes to make gawk recognize the whole expression, but the inner single quotes must be double quotes as well, so they need to be escaped: gawk "{print $1|\"sort\"}" somefile –  Ansgar Wiechers Sep 20 '12 at 9:19
    
@AnsgarWiechers: Thanks for the correction. I'll update the answer accordingly. –  RedGrittyBrick Sep 20 '12 at 10:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.