-
Notifications
You must be signed in to change notification settings - Fork 1
bash
Bash and bash utils: how to do some stuff on the command line. Scripting, common utils, etc.
I never learned EMACS, so I never remember this stuff. But it's handy e.g. when you're trying to edit a line in IRC or something.
https://en.wikipedia.org/wiki/GNU_Readline
for file in *.png; do mv "$file" "${file/pattern/pattern}"; done
-
Find by file name/type:
find . -type f -name *.css
-
Find by recently changed:
find . -type f -name *.vue -ctime -3
- Search .js, .jsx, .vue files, ignore case:
ag --js -i orderservice
-
C-z
to suspend a job, like vim e.g. -
jobs
to see suspended job -
fg %n
to "foreground" a suspended job by its number. (Or justfg
to resume the most recent job.)
change png
to jpg
or whatever as needed
#!/bin/bash
num=`echo $1 | sed -n 's/\([0-9]*\).png/\1/p'`
paddednum=`printf "%03d" $num`
echo ${paddednum}.png
Test it with ./zeropad.sh 1.png
or whatever. When you're confident it works,
you can:
for i in *.jpg; do mv $i `./zeropad.sh $i`; done
for i in {1..5}
do
echo "Hello `printf "%03d" $i`"
done
Create a patchfile:
diff -u original new > patchfile
apply the patch:
patch < patchfile
Diff two directories (optionally include -pN where N = depth):
diff -ru original/ new/ > patchfile
Reverse a diff
patch -R < patchfile
make some weird lo-res images:
convert img.png +dither -remap netscape: convert_img.png