Skip to main content
Image

r/bash


Wrote a full macOS diagnostic in bash 3.2 (the one Macs ship). War stories: ps -r doesn't sort by RAM, and grep -c can print 0 twice
Wrote a full macOS diagnostic in bash 3.2 (the one Macs ship). War stories: ps -r doesn't sort by RAM, and grep -c can print 0 twice

Target was the stock /bin/bash on every Mac, so bash 3.2, no associative arrays, no mapfile, awk doing the heavy lifting.

Two bugs worth sharing. First: ps -Aero rss,comm looks like "all processes sorted by RSS" but -r sorts by CPU. My "top 5 by RAM" list shipped sorted by CPU and looked plausible for days before I caught a 26 MB process listed above a 280 MB one. It's -m for memory sort. Second: grep -c prints "0" AND exits nonzero on no matches, so count=$(... | grep -c x || echo 0) gives you "0\n0" and an integer comparison error later. The fallback echo was the bug.

Per-app memory aggregation (summing helper processes per .app bundle) turned out to be a 12-line awk program. The sticky bottom progress bar is DEC scroll regions plus a WINCH trap.

https://github.com/Ali-expandings/mactune


Linux basics command lines
Linux basics command lines
tips and tricks
Image r/bash - Linux basics command lines

wget returning "No such file or directory" when using -O
wget returning "No such file or directory" when using -O
help

Noob here so sorry if I leave out any needed info, happy to clarify anything :3

wget -O ~/Downloads/file.flatpak "https://website.com/file-get.py?ident=superlongstringofcharacters&file=morebullshit.flatpak&evenmore=bullshit"

Returns:

/home/user/Downloads/file.flatpak: No such file or directory

It was my understanding that if I give it a directory to write to and there's nothing there it would just write there anyways? I just don't want the file to go under said insanely long url. What am I doing wrong