#!/bin/bash
# Setting the Variables for execution
LOGDIR=$HOME
CURRENTTIME=$(date +"%Y%m%d%s%H%M%S")
LOGFILE=${LOGDIR}/chgpermission_${CURRENTTIME}.log
MASTERFILE=$1
INDEX=0
# Checking the number of Parameters passed
if [ "$#" -ne 1 ]; then
echo "Master file name is mandatory parameter" > ${LOGFILE}
exit 1
fi
# Loading the Master file into an Array
echo "Loading the Master file ${MASTERFILE} into an array" >> ${LOGFILE}
while read line
do
#echo $line
MASTERARRAY[$INDEX]=$HOME/$line
INDEX=$(expr $INDEX + 1)
done < ${MASTERFILE}
echo "Number of parameters in an master array ${MASTERARRAY[@]}" >> ${LOGFILE}
# Changing the permission of the file
echo "Changing the permission of the file in master file ${MASTERFILE}" >> ${LOGFILE}
index=0
for index in "${MASTERARRAY[@]}"
do
if [ -f "$index" ]
then
echo "$index file exist"
echo "$index file exist" >> ${LOGFILE}
chmod 755 "$index"
chown workstation "$index"
chgrp workstation "$index"
else
echo "$index file does not extst"
echo "$index file does not exist" >> ${LOGFILE}
fi
done
Вы можете сделать это с помощью следующего кода bash
#!/bin/bash
x=$(pactl list sinks | grep '^[[:space:]]Volume:' | head -n $(( $SINK + 1 )) | tail -n 1 | sed -e 's,.* \([0-9][0-9]*\)%.*,\1,' )
if [[ $x -le 200 ]]
then
pactl set-sink-volume 0 +5%
fi
В этом томе хранится переменная x