first line:
#!/bin/bash #input parameters count:
$#
#script parameters:
$0 - self name, $1 ... $9 - input params
#check that file exist, the spaces near "[" and "]" are required :
if [ -e "streamcount.info" ]
then
echo 'file exist info'
fi
#get file extension:
SHORTFILENAME=$(basename $FULLFILENAME)
DEST_EXT=${SHORTFILENAME##*.}
#get temporary file name:
TFILE="/tmp/streaminfo.$RANDOM.$$.tmp"
#working directory:
$PWD
#redirect error stream to console and filter strings that contain word "Stream":
ffmpeg -i "$SRC" 2>&1 | grep "Stream"
#count strings with grep -c and put it into variable:
a=$( cat < $TFILE | grep -c "Audio:" )
#save command result as array with ( $( ) ):
s=( $( cat < $TFILE | grep "Audio:" | cut -f 2 -d "#" | cut -f 1 -d "(" ) )
#print array contents:
echo "stream numbers: ${s[@]:0}"
#use "for" construction:
for i in `seq 2 $a`;
do
index=$( echo "$i-1" | bc )
v="${s[index]}"
echo "$i. $v"
done
#extract float value:
x=$( echo "qwerty: 123.123123 !" | sed "s/.*[^0-9]\([0-9]\.[0-9]*\).*/\1/g" )
#float point operations:
echo "(256 / $x) / 10" | bc
for float result:
bc -l
# Checks for root privileges
if [ "$(whoami)" != 'root' ]
then
echo "You need to be root to execute uphosts. Exiting!"
exit 1
fi
# Checks required packages
ABORT=0
builtin type -P wget &>/dev/null || { echo -n "wget is missing."; ABORT=1; }
builtin type -P unzip &>/dev/null || { echo -n "unzip is missing."; ABORT=1; }
builtin type -P fromdos &>/dev/null || { echo -n "fromdos(tofrodos) is missing."; ABORT=1; }
builtin type -P grep &>/dev/null || { echo -n "grep is missing."; ABORT=1; }
if [ $ABORT != 0 ]
then
echo " Exiting!"
exit 2
fi
Комментариев нет:
Отправить комментарий