Created
October 12, 2021 14:15
-
-
Save Faheetah/d4d3a4f4fae82d79002bbc51b3b5ed90 to your computer and use it in GitHub Desktop.
Bash tricks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set a loop for running commands, will run unit tests on enter | |
while read; do go test ./...; done | |
# set a loop that runs once a second (like watch), can be used in cases watch doesn't fit as well | |
while sleep 1; do ls; done | |
# do something with the previous command | |
pwd | |
ls $(!!) # equivalent to ls $(pwd) | |
# reverse sort by third column and display top entry (useful for things like ps aux) | |
| sort -k 3 -r | head -1 | |
# sort by unique entries and display the count, also sorted | |
| sort | uniq -c | sort | |
# sort by human readable sizes, in this example with du with depth 1 (syntax may vary by OS) and show top 20 for current folder | |
du -d 1 -h . | sort -nr | head |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment