News for hackers. Stuff that matters.
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by eb0la on Wednesday May 23, 2018 @06:45PM (#17139147)
You just need to master a few commands:

Find (take a look at -exec option)

Cut (or awk)

Sed (for simple text/string substitutions)

Xargs

Dd (that beast can do charset transtation from ASCII to EBCDIC to use in mainframes and can also wipe disks)

And bash of course :)

Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by jake_morrison on Wednesday May 23, 2018 @10:57PM (#17140706)
One fun thing is that xargs supports parallelization.

    -P max-procs
    Run up to max-procs processes at a time; the default is 1.
    If max-procs is 0, xargs will run as many processes as
    possible at a time.  Use the -n option with -P; otherwise
    chances are that only one exec will be done.

    -n max-args
    Use at most max-args arguments per command line.
    Fewer than max-args arguments will be used if the size
    (see the -s option) is exceeded, unless the -x option is
    given, in which case xargs will exit.
So here is a "map/reduce" job which takes the log files in a directory and processes them in parallel on eight CPUs, then combines the results.

    find . -name "*.log" | sort | xargs -n 1 -P 8 agg_stats.py | sort | merge_periods.py
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by Groxx on Thursday May 24, 2018 @03:29AM (#17141817)
xargs is one of my favorites, it's so easy to split something apart to speed it up by a few multiples.

gotta SSH into 100 machines and ask them all a simple question? xargs will trivially speed that up by at least 10x, if not better, just by parallelizing the SSH handshakes.

Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by adrianN on Thursday May 24, 2018 @12:37AM (#17141135)
And for cases where xargs parallelism isn't flexible enough, there is GNU parallel.
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by IndustrialJane on Monday May 28, 2018 @11:53PM (#17176355)
But that approach is potentially dangerous. See:

https://mywiki.wooledge.org/BashPitfalls#Non-atomic_writes_w...

Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by eanzenberg on Wednesday May 23, 2018 @07:50PM (#17139575)
"master a few commands"

"awk"

brb 15 years

Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by buserror on Thursday May 24, 2018 @07:21AM (#17142921)
Not really. awk is pretty simple, basically I just assume it's plain C with a huge regexp pattern 'switch' case at the top level, then I google again for the arguments to substr() :-)
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by heyoni on Thursday May 24, 2018 @09:06AM (#17143553)
Brb in 20 years then.
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by ccozan on Thursday May 24, 2018 @05:32AM (#17142423)
Might be true. The sed&awk from O'Reilly still lingers on my desk from time to time. And I bought it 20 years ago.
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by tjr225 on Wednesday May 23, 2018 @10:56PM (#17140698)
Some of these have come up for me recently, particular sed, awk, and xargs. Xargs in particular is really gnarly and opens up a lot of possibilities from the command line when used in conjunction with other tools. Love it!

Not a program, but another fun bash thing I've learned about recently is brace expansion: https://www.linuxjournal.com/content/bash-brace-expansion

Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by throwaway5752 on Thursday May 24, 2018 @02:16AM (#17141500)
'man' is probably the most indispensable.
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by jonhendry18 on Sunday May 27, 2018 @02:47AM (#17165810)
I find 'apropos' pretty indispensable, because it lets you find the thing that does the thing you need, so you can read its man page.
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by commandlinefan on Thursday May 24, 2018 @10:41AM (#17144404)
That sounds interesting. Is it documented anywhere?
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by throwaway5752 on Thursday May 24, 2018 @11:01AM (#17144645)
No, it's something neckbeards pass along to junior sysadmins, and it's hidden very deep in /dev/null.
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by sidlls on Wednesday May 23, 2018 @07:26PM (#17139414)
awk is so beautiful. A good awk one-liner can beat fancy pandas all day long in some cases.
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by flukus on Wednesday May 23, 2018 @08:23PM (#17139782)
I hate how awk gets so much praise for one liners when it's so good at building things like state machines too: https://two-wrongs.com/awk-state-machine-parser-pattern.html

I've got some similar ones for work that take data csv like data and output sql. A little bit of vim-foo on the csv (yy10000p) and I've got all the test data I need.

Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by cosmie on Wednesday May 23, 2018 @08:33PM (#17139852)
If anything, awk should get some praise for it's flexibility to go from one liners to Doom-style 3d games[1]!

[1] https://github.com/TheMozg/awk-raycaster

Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by cwilkes on Thursday May 24, 2018 @07:39AM (#17143005)
An example here would be nice.
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by hoffbrau99 on Wednesday May 23, 2018 @07:47PM (#17139549)
Don't forget grep!
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by pisky on Wednesday May 23, 2018 @08:29PM (#17139829)
Also, 'parallel' if you've got any idle cores on your infrastructure.
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by foobarian on Wednesday May 23, 2018 @08:52PM (#17139964)
And perl -pe or -ne ! :)
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by Groxx on Thursday May 24, 2018 @03:31AM (#17141833)
^ the moment you do anything even slightly non-trivial with sed, abandon it and use perl instead. for even simple regexes with a couple non-"match this char" segments I regularly see almost 100x speedup, it's rather crazy. it's also a LOT more portable in my experience because the regex engine is so much more capable and consistent, even across fairly major perl versions.
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by crehn on Thursday May 24, 2018 @09:34AM (#17143789)
Honorable mention to jq. Also get comfy with Unix pipes and streams.

e.g. testing in CI a JSON file is properly formatted:

  jq . < $f | diff -u $f -
Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by frou_dh on Friday May 25, 2018 @01:58AM (#17150978)
Personally, I'm not too interested in any commands that take string arguments in their own homegrown programming language[0]. I'd rather use something like this[1] than jq, to get some extra ROI out of one of the languages I already know.

[0]: https://stedolan.github.io/jq/manual/

[1]: https://github.com/antonmedv/fx

Re:Command-line Tools can be 235x Faster than a Hadoop Clust... by rickycook on Thursday May 24, 2018 @03:18AM (#17141749)
adding socat into the mix if you do network related things! it’s amazing what you can do when you replace bits and pieces of a pipe chain with network endpoints