/ mozey.co / blog


April 18, 2016

🔗 Upgrade bash on macOS

“The reason that Apple includes such an old version of Bash in its operating system has to do with licensing. Since version 4.0 (successor of 3.2), Bash uses the GNU General Public License v3 (GPLv3), which Apple does not (want to) support” Upgrading Bash on macOS

brew install bash

which -a bash

bash --version

# Add /usr/local/bin/bash to shells
vi /etc/shells

# Set default shell
chsh -s /usr/local/bin/bash

🔗 List running processes

Include PID $2 and COMMAND $11 columns

ps aux | awk {'print ($2"\t\t", $3"\t\t", $4"\t\t", $9"\t\t", $10"\t\t", $11)'}

Sort on PID and keep top 10 results only

ps aux | awk {'print ($2"\t\t", $3"\t\t", $4"\t\t", $9"\t\t", $10"\t\t", $11)'} | sort -k2rn

🔗 List all cronjobs for all users

sudo su
for user in $(cut -f1 -d: /etc/passwd); do echo $user; crontab -u $user -l; done

🔗 Count lines of code in a directory

find . -name '*.js' | xargs wc -l