2
0
mirror of https://github.com/chubin/cheat.sheets synced 2024-11-19 03:25:44 +00:00

Merge pull request #81 from terminalforlife/master

Additional New Entries, Counters, and Files
This commit is contained in:
Igor Chubin 2019-11-06 20:42:58 +01:00 committed by GitHub
commit 134e596b71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 16 deletions

View File

@ -1,24 +1,21 @@
# To resize an image to a fixed width and proportional height:
# Resize an image to a fixed width and proportional height:
convert original-image.jpg -resize 100x converted-image.jpg
# To resize an image to a fixed height and proportional width:
# Resize an image to a fixed height and proportional width:
convert original-image.jpg -resize x100 converted-image.jpg
# To resize an image to a fixed width and height:
# Resize an image to a fixed width and height:
convert original-image.jpg -resize 100x100 converted-image.jpg
# To resize an image and simultaneously change its file type:
# Resize an image and simultaneously change its file type:
convert original-image.jpg -resize 100x converted-image.png
# To resize all of the images within a directory:
# To implement a for loop:
for file in `ls original/image/path/`;
do new_path=${file%.*};
new_file=`basename $new_path`;
convert $file -resize 150 conerted/image/path/$new_file.png;
# Resize all of the images within a directory, using a for loop:
for file in original/image/path/*; do
convert "$file" -resize 150 converted/image/path/"$file"
done
# Make text annotatation (text = Flower)
# Make text annotation (text = Flower)
convert flower.jpg -font courier -fill white -pointsize 20 -annotate +50+50 'Flower' flower_annotate1.jpg
# Crop an image
@ -33,3 +30,5 @@ convert -border 1x1 -bordercolor "#FFFFFF" image.png new-image.png
# Convert PNG to JPEG (with 70% quality)
convert -quality 70 image.png new_image.jpg
# Apply vignette and grayscale effects to all JPGs in the CWD, using a for loop.
for FILE in *.jpg; { convert -background black -colorspace gray -vignette 200x100 "$FILE" "$FILE"; }

View File

@ -56,3 +56,6 @@ find . -type f -iname '*.png' -exec bash -c 'mv "$0" "${0%.*}.jpg"' {} \;
# Use logic and grouping to delete extension-specific files.
find \( -iname "*.jpg" -or -iname "*.sfv" -or -iname "*.xspf" \) -type f -delete
# List all executable files, by basename, found within PATH.
find ${PATH//:/ } -type f -executable -printf "%P\n"

7
sheets/nl Normal file
View File

@ -0,0 +1,7 @@
# Number lines given to `nl` via STDIN.
printf "Here\nis\nsome\nexample\ntext." | nl
# Number (all) lines given to `nl` via provided file(s).
nl -b a /path/to/file
# The above can also be achieved with `cat`, which is perhaps more portable:
cat -n /path/to/file

2
sheets/sed Normal file
View File

@ -0,0 +1,2 @@
# Edit a file, via substitution, in-place; changes are made to the file(s).
sudo sed -i 's/Name=Xfce Session/Name=Xfce_Session/' /usr/share/xsessions/xfce.desktop

View File

@ -1,13 +1,17 @@
# find all file name ending with .pdf and remove them
# Find all file names ending with .pdf and remove them
find -name \*.pdf | xargs rm
# The above, however, is preferable written without xargs:
find -name \*.pdf -exec rm {} \+
# Or, for find's own functionality, it's best as:
find -name \*.pdf -delete
# find all file name ending with .pdf and remove them
# Find all file name ending with .pdf and remove them
# (bulletproof version: handles filenames with \n and skips *.pdf directories)
# -r = --no-run-if-empty
# -n10 = group by 10 files
find -name \*.pdf -type f -print0 | xargs -0rn10 rm
# if file name contains spaces you should use this instead
# If file name contains spaces you should use this instead
find -name \*.pdf | xargs -I{} rm -rf '{}'
# Will show every .pdf like:
@ -15,6 +19,8 @@ find -name \*.pdf | xargs -I{} rm -rf '{}'
# &titi.pdf=
# -n1 => One file by one file. ( -n2 => 2 files by 2 files )
find -name \*.pdf | xargs -I{} -n1 echo '&{}='
# The above is, however, much faster and easier without xargs:
find -name \*.pdf -printf "%p\n"
# group words by three in a string
seq 1 10 | xargs -n3 echo
# Group words by three in a string
seq 1 10 | xargs -n3