Format input if it's JSON
some-command | jq -R -r '. as $line | try fromjson catch $line'
Run command in a loop with substitution
array=( one two three )
for i in "${array[@]}"; do commaind $i ; done
Run command x times
for run in {1..3}; do command ; done
Voice signal after command finished
command ; say "command finished"
Rename files (requires ZSH)
autoload zmv
# dry run
zmv -n '(**/)(*).andnav' '$1$2.tile
# execute
zmv -n '(**/)(*).andnav' '$1$2.tile
# real-life example
zmv '(**/)(*)hydra(*)' '$1$2minerva$3'
Compare files in two directories
diff -Naur components modal
Rename .ts
files to .tsx
:
find . -name "*.ts" -exec rename 's/\.ts$/\.tsx/' '{}' \;