1
score
|
Log and verify files received via FTP$ for i in $(cat /var/log/vsftpd.log | grep $DATE_TIME | grep UPLOAD | grep OK); do ls /FTP/HOME/$i >> /dev/null 2> \&1; if \[ $? = 0 \]; then echo "$i" >> $FILES_OK_UPLOADS.log; else echo "$DATE ERROR: File $i not found" >> $FTP_FILES_NOTOK_$DATE_TIME.log; fi; done |
1
score
|
Edit the Gimp launcher file to disable the splash screen$ printf '%s\n' ',s/^Exec=[^ ]*/& -s/' w q | ed /usr/share/applications/gimp.desktop |
0
score
|
Edit the Gimp launcher file to disable the splash screen$ sudo sed -i 's/^Exec=[^ ]*/& -s/' /usr/share/applications/gimp.desktop |
0
score
|
`less` is more convenient with the `-F` flag$ less -F FILE1 |
0
score
|
Append to a file text, a blank line, and the last line of another file$ { echo some text; echo; tail -n1 /var/log/apache2/error.log; } >> /path/to/file |
0
score
|
Append to a file text, a blank line, and the last line of another file$ echo -e "From: me\n\n$(tail -n1 /var/log/apache2/error.log)" >> file |
-1
score
|
Run a local shell script on a remote server without copying it there$ ssh user@server bash < /path/to/local/script.sh |
0
score
|
Convert a list of terms in slug format to capitalized words$ sed -e 's/^./\U&/' -e 's/_./\U&/g' -e 's/_/ /g' /path/to/input |
0
score
|
Execute different commands with find depending on file type$ find /path/to/dir -type d -exec chmod 0755 '{}' \; -o -type f -exec chmod 0644 '{}' \; |
0
score
|
Convert m4a files to mp3 using faad and lame$ faad -o tmp.wav music.m4a && lame -b 192 tmp.wav music.mp3 |
0
score
|
Write both stdout and stderr to the same file$ do_something.sh &> out.log |
0
score
|
Create or mount an encrypted directory using encfs$ encfs -i 5 $PWD/raw $PWD/content |
1
score
|
Faster disk imaging with dd$ dd if=/dev/sda bs=$(hdparm -i /dev/sda | grep BuffSize | cut -d ' ' -f 3 | tr [:lower:] [:upper:] | tr -d BUFFSIZE=,) conv=noerror | dd of=image.dd conv=noerror |
0
score
|
Run a never-ending process in the background in a way that you can check on its status anytime$ screen -d -m -S some_name ping my_router |
0
score
|
Make a hexdump or do the reverse with the xxd command$ xxd /path/to/binary/file |
0
score
|
Really lazy way to print the first instance of $foo that occurs after $bar$ ifconfig | grep ^en1 -A5 | grep inet | head -n 1 |
0
score
|
Print the first instance of $foo that occurs after $bar$ sed -n '\@interface Ethernet3/1@,/!/ s/ip address/&/p' file... |
0
score
|
Print the first instance of $foo that occurs after $bar$ awk '/interface Ethernet3\/1/ {instanza=1} /!/ {instanza=0} instanza && /ip address/ {print}' file... |
0
score
|
Sort du output in Human-readable format$ du -hsx * | sort -rh |
0
score
|
Replace symlinks with the actual files they are pointing at$ find /path/to/dir -type l -exec sh -c 'cp --remove-destination "$(readlink "{}")" "{}"' \; |
0
score
|
Expire a user's password immediately$ chage -d 0 USERNAME |
0
score
|
Convert any 16:9 video to play on a QHD widescreen Android phone$ ffmpeg -i $1 -y -threads 0 -subq 6 -deinterlace -level 30 -f mp4 -acodec libfaac -ab 160k -ar 24000 -ac 2 -vcodec libx264 -b 1000k -maxrate 1000k -bufsize 2000k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -coder 0 -refs 2 -flags +loop -vol 256 -trellis 1 -me_method umh -async 1 $2 |
3
score
|
Create a visual report of the contents of a usb drive$ find /path/to/drive -type f -exec file -b '{}' \; -printf '%s\n' | awk -F , 'NR%2 {i=$1} NR%2==0 {a[i]+=$1} END {for (i in a) printf("%12u %s\n",a[i],i)}' | sort -nr |
0
score
|
Sort du output in Human-readable format$ for i in G M K; do du -hsx * | grep "[0-9]$i\b" | sort -nr; done 2>/dev/null |
0
score
|
Sort du output in Human-readable format$ for i in $(echo -e 'G\nM\nK'); do du -hsx /* 2>/dev/null | grep '[0-9]'$i | sort -rn; done |