convert -resize 50% original.png resized.jpg
convert is part of the ImageMagick package.
find . -name '*.js' ! -path '*/vendor/*'
git grep -l 'pattern' | xargs sed -i 's/pattern/relacement/g'
paste -s -d':'
Useful when the output of one command in on multiple lines, and a single line is wanted.
(Without having to count its index)
grep 'pattern' | rev | cut -d'/' -f 1 | rev
Uses the rev command to reverse all characters, select the first field,
then reverse again.
$!!
To repeat the previous command but replace the first occurence of "foo" with "bar":
$ !!:s/foo/bar
For a global substitution:
$ !!:gs/foo/bar
See Event designators in man bash.
mv supports a --backup option to rename the source file if a destination
of the same name exists.
Example with the tree below:
src/
|__ bar
|__ foo
dest/
|__ foo
Running:
# use 'numbered' backup
$ mv --backup=t src/* dest/results in:
src/
dest/
|__ bar
|__ foo
|__ foo.~1~ # original dest/foo
!!:s/foo/bar