CLI Fu
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}'
Backup Audio CDs
Backup Backup
cd /media/bob rsync -avz --size-only --delete Seagate\ Backup\ Plus\ Drive/Media/ Seagate\ Portable\ Drive/Media/
Store Image
cdrdao read-cd --read-raw --driver generic-mmc:0x20000 --datafile cdimage.bin cdimage.toc && toc2cue cdimage.toc cdimage.cue
cdrdao read-cd --read-raw --datafile audiocd.bin --device /dev/cdrom --driver generic-mmc-raw audiocd.cue
Convert BIN/CUE to Ogg Format
To convert a `audiocd.bin` and `audiocd.cue` file to Ogg format, you'll need to follow a two-step process:
- Split the raw BIN audio file into individual tracks using the CUE sheet.
- Convert the individual tracks to Ogg format.
Here's a step-by-step guide:
1. Install Necessary Tools:
Depending on your distribution, you'll need to install some tools. For the purpose of this guide, we'll use `cuetools` and `shntool` for splitting, and `ffmpeg` for conversion.
- Debian/Ubuntu:
sudo apt-get install cuetools shntool ffmpeg vorbis-tools
- Fedora:
sudo dnf install cuetools shntool ffmpeg vorbis-tools
2. Split the BIN File into Individual Tracks:
Navigate to the directory containing your `.cue` and `.bin` files and run:
shnsplit -f audiocd.cue -t "%n-%t" -o wav audiocd.bin
This will produce WAV files named like `01-Trackname.wav`, `02-Trackname.wav`, etc.
3. Convert WAV Files to Ogg Format:
for file in *.wav; do
ffmpeg -i "$file" "${file%.wav}.ogg"
done
This script will iterate over each WAV file and convert it to Ogg using `ffmpeg`. The resulting files will have the same base name as the original WAV files but with an `.ogg` extension.
4. Clean Up (Optional):
If you're satisfied with the Ogg files and no longer need the WAV files, you can delete them:
rm *.wav
You should now have individual Ogg tracks extracted from your audio CD BIN/CUE image.
Summary
shnsplit -f audiocd.cue -t "%n-%t" -o wav audiocd.bin for file in *.wav; do ffmpeg -i "$file" "${file%.wav}.ogg" done rm *.wav