0% found this document useful (0 votes)
3 views2 pages

Shell Program

The document contains a series of shell script examples demonstrating various file operations in a directory. Examples include listing files, checking file permissions, identifying whether entries are files or directories, and converting lowercase filenames to uppercase. Each example uses loops and conditional statements to perform the specified tasks.

Uploaded by

sivakami
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Shell Program

The document contains a series of shell script examples demonstrating various file operations in a directory. Examples include listing files, checking file permissions, identifying whether entries are files or directories, and converting lowercase filenames to uppercase. Each example uses loops and conditional statements to perform the specified tasks.

Uploaded by

sivakami
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

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

You might also like