Timeline for Cannot use awk in alias command chain
Current License: CC BY-SA 4.0
7 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 22, 2021 at 22:31 | vote | accept | blnks | ||
| Oct 22, 2021 at 21:01 | answer | added | glenn jackman | timeline score: 2 | |
| Oct 22, 2021 at 15:54 | comment | added | Chris Davies | @glennjackman as an answer, please :-) | |
| Oct 22, 2021 at 15:47 | comment | added | glenn jackman | This is one reason why functions are better than aliases: you can avoid quoting hell. ttn() { tail -10000 /var/log/nginx/access.log | awk '{print $1}' | sort | uniq -c | sort -nr | head -10"; } | |
| Oct 22, 2021 at 14:59 | comment | added | blnks | backslashing only $ does not work but this one is fine: alias ttn='tail -10000 /var/log/nginx/access.log | awk '\''{print $1}'\'' | sort | uniq -c | sort -nr | head -10' . Please answer and I'll accept. | |
| Oct 22, 2021 at 14:31 | comment | added | Ed Morton | Are you sure you need awk anyway and not just cut -d' ' -f1? It depends what the first white space is in your input file - if every line starts with non-white-space followed by a blank char then you can just use cut instead of awk (which would be slower). | |
| Oct 22, 2021 at 12:52 | history | asked | blnks | CC BY-SA 4.0 |