command line interface (cli) tips

A web page for gathering various tips and commands for the command line interface (cli) to share with friends, students, colleagues and collaborators.

basics

When you open the command line interface (cli) - you will likely see something like this:

[your user name]@[your machine's name] ~ % 

The command line runs prompts from within a folder.

Where are you? You will likely start out in your “home” folder.

To check where you are you can try to “print working directory”:

pwd

What is in this directory?

To find out you can try “listing” what is there:

ls

Maybe there is a mix of files and folders.

You can try listing only the folders:

ls -d */

You may see a list of folders like this:

Applications/
Desktop/
Documents/
Downloads/
Library/
Movies/
Music/
Pictures/

To change into the Downloads folder, for example, you can “change directory”:

cd Downloads

cwebp

convert input.png into a compressed WebP image at quality 82, saving it as output.webp

cwebp -q 82 input.png -o output.webp

ffmpeg

extract the audio from a video as a wav file:

ffmpeg -i input.mp4 -vn -acodec pcm_s16le -ar 48000 -ac 2 output.wav

extract 1 frame from 1 second of video input.mp4 and save image as output.png:

ffmpeg -ss 1 -i input.mp4 -vframes 1 output.png

grep

todo

image magick

todo

man

read the manual page for ffmpeg:

man ffmpeg

moviepy

todo

nano

open a text file in nano:

nano notes.txt

yt-dlp

video

download the best quality video (H.264) and audio (M4A) from <video url> merging them into an MP4 when available, otherwise falling back to the best MP4 or best available format

yt-dlp -f 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best' -S vcodec:h264,res,acodec:m4a <video url>

audio

download the best available audio from a video url as a wav file with a useful filename:

yt-dlp -f "bestaudio" --extract-audio --audio-format wav --audio-quality 0 -o "%(upload_date)s_%(uploader)s_%(title).60s.%(ext)s" <video url>

get a wav file with the best quality audio of a list of video urls urls.txt:

yt-dlp -f "bestaudio" --extract-audio --audio-format wav --audio-quality 0 -o "%(id)s.%(ext)s" -a urls.txt

get the best available audio from a video url as an mp3:

yt-dlp -f "bestaudio" --extract-audio --audio-format mp3 --audio-quality 0 <video url>

vclip

todo

videogrep

todo

zsh

reset

source ~/.zshrc