Difference between revisions of "Shell Tricks"
(→Random) |
(→Random) |
||
Line 6: | Line 6: | ||
<pre>youtube-dl -f best 'http://example.com'</pre> | <pre>youtube-dl -f best 'http://example.com'</pre> | ||
Extract audio to mp3 | Extract audio to mp3 | ||
− | <pre>youtube-dl -f best --extract-audio --audio-format mp3 'http://example.com'</pre> | + | <pre>youtube-dl -f best --extract-audio --audio-format mp3 --audio-quality 0 'http://example.com'</pre> |
Bump audio volume (256 is base level so 512 would double) | Bump audio volume (256 is base level so 512 would double) | ||
<pre>ffmpeg -i file.mp3 -vol 512 output.mp3</pre> | <pre>ffmpeg -i file.mp3 -vol 512 output.mp3</pre> |
Latest revision as of 21:17, 11 August 2019
Random
Get the best quality via youtubedl
youtube-dl -f best 'http://example.com'
Extract audio to mp3
youtube-dl -f best --extract-audio --audio-format mp3 --audio-quality 0 'http://example.com'
Bump audio volume (256 is base level so 512 would double)
ffmpeg -i file.mp3 -vol 512 output.mp3
Get certs and other TLS info
openssl s_client -connect nextcloud.racklinux.net:443 -servername nextcloud.racklinux.net -showcerts
Kill all of something
ps aux | grep prog_name | awk '{print $2}' | xargs kill -9
Create/Restore a compressed dd image of a disk
dd status=progress if=/dev/sde conv=sync,noerror bs=64K | gzip -c > /storage_loc/file_name.img.gz zcat /storage_loc/file_name.img.gz | dd status=progress of=/dev/sde
Get the round trip time of a website (in seconds):
curl -s -w "%{time_total}\n" -o /dev/null http://www.google.com
Find and remove:
find ./ -name *.m3u -exec rm -v {} +
Find but exclude irritating directories:
find / -path /sys -prune -o -path /proc -prune -o -iname blah
Compare two directory trees:
find directory1 -type d -printf "%P\n" | sort > file1 find directory2 -type d -printf "%P\n" | sort | diff - file1
In the following command any output (STDOUT AND STDERR) is piped to the next command. This works well with tee because then your log will have both types of output just like your shell window. This has been tested in tcsh, but will likely work in other shells.
/run/any/command.sh |& tee log.txt
Empty a file.
: > ./file
Clear swap space and adjust swappiness
swapoff -a && echo -e "\nvm.swappiness=1" >> /etc/sysctl.conf && sysctl -p && swapon -a
Dump http headers and call (don't forget to change the port)
stdbuf -oL -eL /usr/sbin/tcpdump -A -s 10240 "tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)" | egrep -a --line-buffered ".+(GET |HTTP\/|POST )|^[A-Za-z0-9-]+: " | perl -nle 'BEGIN{$|=1} { s/.*?(GET |HTTP\/[0-9.]* |POST )/\n$1/g; print }'
Sed One Liners
Remove a line that contains a specific string
sed -i '/pattern to match/d' ./infile
If instead you'f like to use perl to delete lines that match a string
perl -i.bak -ne 'print unless m/some_pattern/' /path/to/infile
You could also use grep
grep -vP 'some_pattern' /path/to/infile
Show specific lines from a file
sed -n '20,40p' file_name