Last active
December 15, 2015 05:20
-
-
Save monolithed/5208696 to your computer and use it in GitHub Desktop.
Bash tricks
This file contains 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
# Who started a process? | |
pgrep PTPCamera | |
ps -O ppid -p 29045 | |
ps -p 202 | |
ps -A -O user | grep /sbin/launchd | |
launchctl list | grep PTPCamera | |
*.debug /var/log/debug.log | |
# ([0x0-0x2d92d9].com.apple.PTPCamera[24472]): Spawned by PID 240: com.apple.SystemUIServer.agent | |
sudo killall -HUP syslogd | |
launchctl list com.apple.SystemUIServer.agent { | |
"Program" = "/System/Library/CoreServices/SystemUIServer.app/Contents/MacOS/SystemUIServer"; | |
}; | |
# find | |
find . -type f -exec file -- {} + | |
find . -type f -exec wc -lcw -- {} + | |
find . -type f -exec file -- {} + 2>&1 | > tee file.txt | |
echo test | awk '{print toupper($1)}' | |
echo test | tr '[:lower:]' '[:upper:]' | |
seq -f %02g 1 10 | |
yes | rm *.txt | |
# jobs | |
kill %1 | |
jobs | |
fg | |
# CR/LF | |
cat infile | sed 's/\r\n$/\n/' | od -c | |
tr -d '\r' < infile > outfile | |
sed -i s/\r// file | |
sed -i -e '/^M/d' input | |
sed -e '/^M/d' -i -r $(find . -type f) | |
# find \r files | |
grep -r $'\r' * | |
# uniq (cut ununiq lines) | |
awk -F, '!array[$1]++' file.txt | |
# passgen | |
# LC_CTYPE=C tr -dc A-Za-z0-9_\!\@\#\$\%\^\&\*\(\)-+= < /dev/urandom | head -c 32 | xargs | |
genpasswd() { | |
local l=$1 | |
[ "$l" == "" ] && l=16 | |
tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs | |
} | |
date +%s | sha256sum | base64 | head -c 32 ; echo | |
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-32};echo; | |
openssl rand -base64 32 | |
tr -cd '[:alnum:]' < /dev/urandom | fold -w30 | head -n1 | |
strings /dev/urandom | grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n'; echo | |
< /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c6 | |
dd if=/dev/urandom bs=1 count=32 2>/dev/null | base64 -w 0 | rev | cut -b 2- | rev | |
</dev/urandom tr -dc '12345!@#$%qwertQWERTasdfgASDFGzxcvbZXCVB' | head -c8; echo "" | |
randpw(){ < /dev/urandom tr -dc _A-Z-a-z-0-9 | head -c${1:-16};echo; | |
date | md5sum} | |
bc <<< 2+3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment