What does the
0 2>&1 >/dev/null below mean?
rawout=$(HandBrakeCLI -i /dev/dvd -t 0 2>&1 >/dev/null)
count=$(echo $rawout | grep -Eao "\\+ title [0-9]+:" | wc -l)
what does the
-Eao "\\+ title [0-9]+:" | wc -l) imply?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
According to HandBreak cli documentation:
-t 0 option means "scan all titles only".
2>&1 >/dev/null is a linux terminal output redirection of your errors (error stream) to your outpus stream (which displays general command and output messages to the terminal), and both of them redirected to
/dev/null special device file wich discards whatever is sent to it.
It is a method of making a command silent and not show you any messages.
grep -Eao "\\+ title [0-9]+:" | wc -l is a combination of the output of
grep -Eao "\\+ title [0-9]+:" sent to the
wc -l command, which counts the number of lines in a file or a command output.
In other words: count how many lines the command
grep -Eao "\\+ title [0-9]+:" outputs.
wc in the wc manpage.
grep util performs a search of a given expression pattern inside a file or a command output:
-a option means "handle this data given as text data".
-E is a deprecated option of
grep which sometimes used to treat patterns as extended regex.
-o means "show only matching results of a whole matching line".
Overall the use of
grep here seems to be a searching mechanism for an series title and episode, and display their name.
grep in the grep manpage.