Last active
September 14, 2020 12:56
-
-
Save panzelva/8d77f2742f7b0f38b051287f28b87276 to your computer and use it in GitHub Desktop.
bash snippets
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
| #!/bin/bash | |
| # Count all files in current folder | |
| ls -1q -U | wc -l | |
| # Example output: | |
| # 262787 |
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
| #!/bin/bash | |
| # To count files by extension in current directory, run this: | |
| ls -q -U | awk -F . '{print $NF}' | sort | uniq -c | awk '{print $2,$1}' | |
| # Example output: | |
| # jpg 192381 | |
| # png 70413 |
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
| #!/bin/bash | |
| # You can manually kill a process when you think the system is swapping too much and something needs to die. This can be done through the kernel SysRq triggers. | |
| # The kernel has what it calls "magic SysRq". This is a bit of functionality that tells the kernel to perform some sort of emergency operation. This can be things like "remount all volumes read-only", "sync all filesystems", or "reboot now". One of these options is also to invoke the OOM killer. | |
| # If your kernel has magic SysRq enabled (kernel option CONFIG_MAGIC_SYSRQ), you can do this this way. | |
| # source https://unix.stackexchange.com/questions/127193/kill-the-biggest-process-button | |
| echo f > /proc/sysrq-trigger |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment