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
Linux utils that you might not know
51–60 of 159 posts
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…
Re: Linux utils that you might not know
#53locate /\*xyzGlobPattern | xargs grep -E '\<abc[(]'
Re: Linux utils that you might not know
#54Which xyz-file buried in the code base has that "abc" function I saw last month? locate /\*xyzGlobPattern | xargs grep -E '\<abc[(]'
Re: Linux utils that you might not know
#55du -hs * | sort -h
Re: Linux utils that you might not know
#56Earlier 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
$ I just tried this on bash 4.3. Cat remains superfluous in this case.
Re: Linux utils that you might not know
#57Re: Linux utils that you might not know
#58Re: Linux utils that you might not know
#59One 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.
Re: Linux utils that you might not know
#60Earlier 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?
ps | grep [g]rep
Though it is still a bit terrible.