[prabhucloudxlab@cxln4 ~]$ cat>1sh.sh
#! bin/bash
# Script for File operators
#-f------------>>files
#-d------------>>directories
#-s------------>>not empty file
#-w------------>>writable files
#-r------------>>readble file
#-x------------>>executable file
echo "enter file_name:"
read file_name
if [ -f $file_name ] #------------->> -f for finding files in directory whether exist or not
then
echo "file $file_name is found"
else
echo "file $file_name is not found"
fi
echo "enter dir_name:"
read dir_name
if [ -d $dir_name ] #------------->> -d for finding directories
then
echo "file $dir_name is found"
else
echo "file $dir_name is not found"
fi
[prabhucloudxlab@cxln4 ~]$ ls -f */
[prabhucloudxlab@cxln4 ~]$ ls -d */
[prabhucloudxlab@cxln4 ~]$ sh 1sh.sh
enter file_name:
ifelse.sh
file ifelse.sh is found
enter dir_name:
prabhu
file prabhu is found
#! bin/bash
# Script for File operators
#-f------------>>files
#-d------------>>directories
#-s------------>>not empty file
#-w------------>>writable files
#-r------------>>readble file
#-x------------>>executable file
echo "enter file_name:"
read file_name
if [ -f $file_name ] #------------->> -f for finding files in directory whether exist or not
then
echo "file $file_name is found"
else
echo "file $file_name is not found"
fi
echo "enter dir_name:"
read dir_name
if [ -d $dir_name ] #------------->> -d for finding directories
then
echo "file $dir_name is found"
else
echo "file $dir_name is not found"
fi
[prabhucloudxlab@cxln4 ~]$ ls -f */
[prabhucloudxlab@cxln4 ~]$ ls -d */
[prabhucloudxlab@cxln4 ~]$ sh 1sh.sh
enter file_name:
ifelse.sh
file ifelse.sh is found
enter dir_name:
prabhu
file prabhu is found