Live data from Hacker News

Linux utils that you might not know

shiroyasha.io

51–60 of 159 posts

Re: Linux utils that you might not know

#51
post #26

Earlier quoted context omitted.

That's not a great example as `pgrep` is a little more nuanced than running `ps [options] | grep [string]`, eg you cannot use many of the same `ps` flags `pgrep` like you can with `ps`. At least with "in appropriate use of cat" (as some call it) you're literally just swapping the stdin file stream with a disk io file stream so there's no functional difference what-so-ever. I'm not saying I agree with the GP either th…

> it's certainly a more logical program flow for a human to parse. ie "open file, grep for contents, do something else, etc". If you mean adding a 'cat' at the start to provide a clear entry-point for the data, you can actually put the redirect at the beginning: cheesy_lines.txt

Indeed, but as I said, the cat complaint tends to be a practice mostly used by those less experienced in the command line so they are probably unaware of `<` let alone that it's placement.

Re: Linux utils that you might not know

#52

* 'comm -3' is a quick way to do a set difference from the command line. * Newer versions of sort have an option for running sorts in parallel. If you're using an older sort, you can split the files, sort them individually with GNU parallel, and use --merge to combine them. * If you have scripts that read data files, process them, and output more files, consider using a Makefile. * tmux is a good way to leave a devel…

> If you have scripts that read data files, process them, and output more files, consider using a Makefile. Dear sweet hypnotoad, don't use Makefiles for this. Scripts in a pipeline are perfectly well suited for ETL. They have the advantage of using the same language as the command language (Makefile is not shell, and when it differs it's a significant surprise). Plus, you can drop a script into a dir in your PATH an…

[deleted]

Re: Linux utils that you might not know

#56
post #49
post #40

Earlier quoted context omitted.

Once I saw this notation, I immediately fell in love: output.txt

You get a blank screen, but if you do: cat file-that-doesnt-exist.txt | less You get a nice error message: cat: 'file-that-doesnt-exist.txt': No such file or directory

Works for me:

$ I just tried this on bash 4.3. Cat remains superfluous in this case.

Re: Linux utils that you might not know

#59
post #30

One note: I believe `shred` won't work as expected on a journaling file system like ext4.

and iirc on SSDs you cant really a file with random bytes. Apple removed the "safe erasure" option from Finder because they couldn't guarantee deletion.

You can, but ssds are internally log structured, you have to overwrite whole free space plus the reserve and then run a TRIM.

Re: Linux utils that you might not know

#60
post #45
post #26

Earlier quoted context omitted.

That's not a great example as `pgrep` is a little more nuanced than running `ps [options] | grep [string]`, eg you cannot use many of the same `ps` flags `pgrep` like you can with `ps`. At least with "in appropriate use of cat" (as some call it) you're literally just swapping the stdin file stream with a disk io file stream so there's no functional difference what-so-ever. I'm not saying I agree with the GP either th…

ps | grep | grep -v grep amirite? pgrep often fails me I think mostly for apps the edit their cmdline and it needs to whole word match I think?

You can avoid literal matches like so:

    ps | grep [g]rep
Though it is still a bit terrible.
Post reply on HN