3 ms·
tldr: grep, cat, find, head / tail, wc, awk, shuf with bonuses of xargs, and man. I've never needed shuf, and awk is a bit out of place in the list, but head a
by 6keZbCECT2uB 8y ago
tldr: grep, cat, find, head / tail, wc, awk, shuf with bonuses of xargs, and man.
I've never needed shuf, and awk is a bit out of place in the list, but head and tail have saved me from many a large file. The interesting data is usually in head, tail, or grep anyway.
- mroche 8y agoDef the first five there. wc as more of a tie-in with the former. Never used shuf and still need to find the time to learn awk.
- deleted 8y ago[deleted]
- scbrg 8y agoWhen it comes to learning awk, my suggestion is to read the man file of one of the simpler implementations; original-awk[0] or plan9's[1] awk. They lack the GNU additions (many of which admittedly are useful), but they decrease the learning curve a lot. I pushed off learning awk for years since I got overwhelmed every time I typed 'man awk', but after stumbling on the man page from plan9 I learned it in no time. Sure, I don't know all the GNU extensions in gawk, but now I can look them up when I need them. [0] https://manpages.debian.org/stretch/original-awk/awk.1.en.html https://manpages.debian.org/stretch/original-awk/awk.1.en.ht... [1] https://www.unix.com/man-page/plan9/1/AWK/ https://www.unix.com/man-page/plan9/1/AWK/
- mroche 8y agoThanks for this! I appreciate the pointers.
- vajrabum 8y agoawk '{print $2,$4;}' is useful and easy to remember. $NF refers to the last field. FS is the variable to override the default field separator of white space. Here's an example of it's use. OFS is the output field separator. awk 'BEGIN{FS=":"; OFS=":"} {print $1,$NF}' /etc/password Works on CSV files too with the right field separator.
- masklinn 8y ago> awk '{print $2,$4;}' is useful and easy to remember. $NF refers to the last field. FS is the variable to override the default field separator of white space. Here's an example of it's use. OFS is the output field separator. Yeah also cut is just inconvenient, awk works much better when working with the usual tabulated data. > Works on CSV files too with the right field separator. You're probably better off using xsv though.
- Noumenon72 8y agoI have used awk several times in different ways. I still don't find it easy to remember a command with as many punctuation characters as letters, like your first one. And I'm not even sure what the second one is trying to do. Print the user name, followed by the number of fields separated by colons? What good is that? Perhaps you've forgotten that not everyone can read awk syntax right off the page.
- emgee_1 8y agoshut I do not know; would add extra random field and then sort