#!/bin/bash
#reading data from the user
read -p 'Enter file name : ' FileName
if [ -e $FileName ]
then
echo File Exist
else
echo File doesnot exist
fi
if [ -s $FileName ]
then
echo The given file is not empty.
else
echo The given file is empty.
fi
if [ -r $FileName ]
then
echo The given file has read access.
else
echo The given file does not has read access.
fi
if [ -w $FileName ]
then
echo The given file has write access.
else
echo The given file does not has write access.
fi
if [ -e $FileName ]
then
echo The given file has execute access.
else
echo The given file does not has execute access.
fi
Last active
April 11, 2019 22:22
-
-
Save chankruze/25c4ae6798484434890187642b025e62 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Call this script with at least 10 parameters, for example
# ./scriptname 1 2 3 4 5 6 7 8 9 10
MINPARAMS=10
echo
echo "The name of this script is \"$0\"."
# Adds ./ for current directory
echo "The name of this script is \"`basename $0`\"."
# Strips out path name info (see 'basename')
echo
if [ -n "$1" ] # Tested variable is quoted.
then
echo "Parameter #1 is $1" # Need quotes to escape #
fi
if [ -n "$2" ]
then
echo "Parameter #2 is $2"
fi
if [ -n "$3" ]
then
echo "Parameter #3 is $3"
fi
# ...
if [ -n "${10}" ] # Parameters > $9 must be enclosed in {brackets}.
then
echo "Parameter #10 is ${10}"
fi
echo "-----------------------------------"
echo "All the command-line parameters are: "$*""
if [ $# -lt "$MINPARAMS" ]
then
echo
echo "This script needs at least $MINPARAMS command-line arguments!"
fi
echo
exit 0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment