exp_12
exp_12
Aim: Write a shell script to display all executable files, directories, and zero-sized
files from the current directory.
Date:
Relevant CO: Evaluate the requirement for process synchronization and coordination
handled by operating system.
Objectives:
1. To educate students about the permission system of UNIX-like operating systems and its
significance.
2. To demonstrate the ability to filter and display directory content based on specific criteria using
shell scripting.
3. To encourage students to explore various commands and options that can be used to glean
information about files.
4. To provide a hands-on experience in creating scripts that present organized information based
on file attributes.
Theory:
In UNIX-like operating systems, files and directories have associated *permissions* that
determine who can read, write, or execute them. An executable file is one that has the execute
permission set for the user, group, or others. Directories with the execute permission can be
accessed and traversed. A zero-sized file, as the name suggests, has a size of 0 bytes.
Using the ls command with specific options and filters, one can list files based on their attributes.
Combined with if conditions, shell scripts can be used to detect and display files with specific
properties.
Procedure:
1. Start the script.
Observations:
Result:
Code:-
Outpute:-
Conclusion: This script demonstrates how to use basic file tests in shell scripting to filter and
display files based on specific properties. It can be helpful for tasks such as organizing files,
performing system checks, or automating system maintenance. By using commands like -x, -d,
and -s, the script is able to classify files effectively based on attributes.
Quiz:
1. How can you identify an executable file in a UNIX-like system?
ANS:- An executable file can be identified by checking if it has the execute permission
(-x) set for the user, group, or others. In a shell script, this can be done using the
[ -x "$file" ] condition.
2. What is the significance of the execute permission on a directory?
ANS:- The execute permission on a directory allows users to enter the directory and
access its contents. Without the execute permission, users cannot navigate into the
directory using the cd command.
Rubrics 1 2 3 4 5 Total
Marks