Ex.
no1
echo " LIST OF FILES IN A CURRENT DIRECTORY"
echo " ------------------------------------"
for entry in `ls $search_dir`; do
echo $entry
done
Ex.no2
# READ,WRITE AND EXECUTABLE PERMISSION
IN FILES
# having read, Write and Execute permission
echo "The name of all files having all permissions :"
# loop through all files in current directory
for file in *
do
# check if it is a file
if [ -f $file ]
then
# check if it has all permissions
if [ -r $file -a -w $file -a -x $file ]
then
# print the complete file name with -l option
ls -l $file
# closing second if statement
fi
# closing first if statement
fi
done
Ex.no3
echo "DIRECTORY OR FILEUSING PASSING ARGUMENTS"
for file in $(ls $dir)
do
[ -f $file ] && echo "$file is file"
[ -d $file ] && echo "$file is directory"
done
[Link]
echo" LOWERCASE TO UPPERCASE IN DIRECTORY"
for file in *
do
if [ -f $file ]
then
echo $file | tr '[a-z]' '[A-Z]'
fi
done