I'm just starting to learn bash. I have the following script, and I would like to know what does the following commands do in order to start to understand a little bit this world.
if [ ! -w "." ]
then
echo "You need write permission in the directory"
exit 1
fi
firefoxGeditOpen=ps -d | grep -ic -e firefox -e gedit
if [[firefoxGeditOpen>0]]
then
echo "Firefox and Gedit must be closed to let the script work"
exit 1
fi
while(true)
do
firefox &
firefoxPid=$!
gedit &
geditPid=$!
echo "Firefox PID $firefoxPid Gedit PID $geditPid">>result.txt
wait
echo "You have closed all the processes. They will be re-opened">>result.txt
done
Thanks in advance!
[[
and]]
should be separated from what's between them (and also from what's outside of them) by whitespace.