Using awk in BASH alias or function

后端 未结 2 1555
北海茫月
北海茫月 2020-12-14 06:35

I\'ve a command that works just fine at the command line, but not when I try to put it in an alias or function.

$ awk \'{print $1}\' /tmp/textfile
0
<         


        
2条回答
  •  臣服心动
    2020-12-14 07:35

    You need to escape the $ like so:

     alias a="awk '{print \$1}' /tmp/textfile"
    

    Otherwise your alias is:

     awk '{print }' /tmp/textfile
    

    Which prints the whole file...

提交回复
热议问题