CLI Fu: Difference between revisions

From Traxel Wiki
Jump to navigation Jump to search
 
(13 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:Hacking]]
[[Category:Hacking]]
= Image Magick =
Convert, noclobber:
<pre>ls webp/*webp | sed 's/webp//g' | awk '{print "[ -f png"$1"png ] || convert webp"$1"webp png"$1"png"}'</pre>
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>
= Awk =
= Awk =
Using Awk for sums:
Using Awk for sums:
Line 11: Line 5:
<pre>ls -l | awk '{sum += $5} END {print sum}'</pre>
<pre>ls -l | awk '{sum += $5} END {print sum}'</pre>


= Backup Audio CDs =
= Audio CDs =
== Backup Backup ==
<pre>
rsync -navz --size-only --delete /media/bob/Seagate\ Backup\ Plus\ Drive/Media/ /media/bob/Seagate\ Portable\ Drive/Media/
</pre>
remove -n for live fire
 
== Store Image ==
== Store Image ==
<pre>
<pre>
Line 71: Line 71:


You should now have individual Ogg tracks extracted from your audio CD BIN/CUE image.
You should now have individual Ogg tracks extracted from your audio CD BIN/CUE image.
=== Summary ===
<pre>
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
</pre>
= FFMpeg =
* <pre>ffmpeg -i audiobook.m4b -acodec libmp3lame audiobook.mp3</pre>
= Portable Drives =
<pre>
lsblk
udisksctl mount -b /dev/sdb1
udisksctl unmount -b /dev/sdb1
</pre>
= Image Magick =
Convert, noclobber:
<pre>ls webp/*webp | sed 's/webp//g' | awk '{print "[ -f png"$1"png ] || convert webp"$1"webp png"$1"png"}'</pre>
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>
= Math =
<pre>ADD=$(( 1 + 2 ))</pre>
= systemctl =
<pre>
systemctl list-units --type=service --all | grep active| grep -v inactive
</pre>

Latest revision as of 17:41, 9 March 2025

Awk

Using Awk for sums:

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

Audio CDs

Backup Backup

rsync -navz --size-only --delete /media/bob/Seagate\ Backup\ Plus\ Drive/Media/ /media/bob/Seagate\ Portable\ Drive/Media/

remove -n for live fire

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:

  1. Split the raw BIN audio file into individual tracks using the CUE sheet.
  2. 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

FFMpeg

  • ffmpeg -i audiobook.m4b -acodec libmp3lame audiobook.mp3

Portable Drives

lsblk
udisksctl mount -b /dev/sdb1
udisksctl unmount -b /dev/sdb1

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"}'

Math

ADD=$(( 1 + 2 ))

systemctl

systemctl list-units --type=service --all | grep active| grep -v inactive