I'm surprised there was no mention of cut -d. It's good for simple stuff where you don't need all of awk.
Useful Unix commands for data science
21–30 of 108 posts
Re: Useful Unix commands for data science
#22Actually useful data science tips for unix users. Make all your commands 3x faster: export LC_ALL=C Actually use the 32 CPUs you paid for: sort --parallel=32 ... xargs -P32 ...
export LC_ALL=C
would "make all your commands 3x faster"?Re: Useful Unix commands for data science
#23I like slicing and dicing with awk, grep and friends too. One thing I find odd that you have to drop to a full language (awk, perl etc) to sum a column of numbers. Am I missing a utility? echo "1\n2\n3\n" | sum # should print 6 with hyphothetical sum command I suppose more generally you could have a 'fold initial op' and: echo "1\n2\n3\n4\n" | fold 0 + # should print 10 echo "1\n2\n3\n4\n" | fold 1 \* # should print…
alias sum='xargs -I{} sh -c "head -c {} Re: Useful Unix commands for data science
#24Actually useful data science tips for unix users. Make all your commands 3x faster: export LC_ALL=C Actually use the 32 CPUs you paid for: sort --parallel=32 ... xargs -P32 ...
Could you expand on why export LC_ALL=C would "make all your commands 3x faster"?
Re: Useful Unix commands for data science
#25A commenter on the article pointed out the "Useless use of cat". What most users probably don't realize is that the redirection can be anywhere on the line, not just at the beginning. Putting an input redirection at the beginning of the command can make the data flow clearer: from the input file, through the command, to stdout: (This only works for simple commands; you can't do `< file if blah; then foo; else bar; fi…
Re: Useful Unix commands for data science
#26Actually useful data science tips for unix users. Make all your commands 3x faster: export LC_ALL=C Actually use the 32 CPUs you paid for: sort --parallel=32 ... xargs -P32 ...
Could you expand on why export LC_ALL=C would "make all your commands 3x faster"?
With the C locale, text is more or less treated as plain bytes.
Re: Useful Unix commands for data science
#27I like slicing and dicing with awk, grep and friends too. One thing I find odd that you have to drop to a full language (awk, perl etc) to sum a column of numbers. Am I missing a utility? echo "1\n2\n3\n" | sum # should print 6 with hyphothetical sum command I suppose more generally you could have a 'fold initial op' and: echo "1\n2\n3\n4\n" | fold 0 + # should print 10 echo "1\n2\n3\n4\n" | fold 1 \* # should print…
Another useful one is "hist" which is sort | uniq -c | sort -n -r.
Re: Useful Unix commands for data science
#28I like slicing and dicing with awk, grep and friends too. One thing I find odd that you have to drop to a full language (awk, perl etc) to sum a column of numbers. Am I missing a utility? echo "1\n2\n3\n" | sum # should print 6 with hyphothetical sum command I suppose more generally you could have a 'fold initial op' and: echo "1\n2\n3\n4\n" | fold 0 + # should print 10 echo "1\n2\n3\n4\n" | fold 1 \* # should print…
paste -sd+|bcRe: Useful Unix commands for data science
#29Starts off with unnecessary use of cat, e.g., cat file | awk 'cmds'. One can simply do awk 'cmds' file.
And if the extra cat is actually making a measurable difference, maybe that's a good signal that it's time to rewrite it in C.
Re: Useful Unix commands for data science
#30Actually useful data science tips for unix users. Make all your commands 3x faster: export LC_ALL=C Actually use the 32 CPUs you paid for: sort --parallel=32 ... xargs -P32 ...