I write the code in a .sh file and run it…
die () {
echo >&2 "$@"
exit 1
}
[ "$#" -eq 2 ] || die "2 argument required, $# provided"
echo $2 | grep -E -q '^[0-9]+$' || die "Numeric argument required, $2 provided"
nfile_location = /home/virtual/$1
if [ -f $nfile_location ];
then
chmod -R $2 $nfile_location
echo "Set permission";
exit 1;
else
echo "Not a correct file";
exit 1;
fi
but it is not working. it shows the following error, which i can not understant as i am new in bash scripting.
/root/new_scripts/setpermission.sh: line 11: nfile_location: command not found
chmod: missing operand after `777'
Try `chmod --help' for more information.
Set permission
There must be no spaces before or after the
=sign.Wrong:
nfile_location = /home/virtual/$1Correct:
nfile_location=/home/virtual/$1