Skip to content

Instantly share code, notes, and snippets.

@panzelva
Last active September 14, 2020 12:56
Show Gist options
  • Select an option

  • Save panzelva/8d77f2742f7b0f38b051287f28b87276 to your computer and use it in GitHub Desktop.

Select an option

Save panzelva/8d77f2742f7b0f38b051287f28b87276 to your computer and use it in GitHub Desktop.
bash snippets
#!/bin/bash
# Count all files in current folder
ls -1q -U | wc -l
# Example output:
# 262787
#!/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
#!/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