CLI Fu: Difference between revisions

From Traxel Wiki
Jump to navigation Jump to search
No edit summary
Line 6: Line 6:
Convert, noclobber, thumbnail:
Convert, noclobber, thumbnail:
<pre>ls png/*png | sed 's/png//g' | awk '{print "[ -f jpg"$1"jpg ] || convert -thumbnail 256x256 png"$1"png jpg"$1"jpg"}'</pre>
<pre>ls png/*png | sed 's/png//g' | awk '{print "[ -f jpg"$1"jpg ] || convert -thumbnail 256x256 png"$1"png jpg"$1"jpg"}'</pre>
= Awk =
Using Awk for sums:
<pre>ls -l | awk '{print $5}' | awk '{sum += $1} END {print sum}'</pre>
<pre>ls -l | awk '{sum += $5} END {print sum}'</pre>

Revision as of 18:27, 17 October 2023

Image Magick

Convert, noclobber:

ls webp/*webp | sed 's/webp//g' | awk '{print "[ -f png"$1"png ] || convert webp"$1"webp png"$1"png"}'

Convert, noclobber, thumbnail:

ls png/*png | sed 's/png//g' | awk '{print "[ -f jpg"$1"jpg ] || convert -thumbnail 256x256 png"$1"png jpg"$1"jpg"}'

Awk

Using Awk for sums:

ls -l | awk '{print $5}' | awk '{sum += $1} END {print sum}'
ls -l | awk '{sum += $5} END {print sum}'