Description of example shell procedure – HP NonStop G-Series User Manual

Page 52

Advertising
background image

2.

Use the chmod +x command to give the file x (execute) status. For example, the command
chmod g+x reserve

gives execute status to the file reserve for any user in your group

(g). See

Chapter 10 (page 121)

, for more information on chmod.

3.

Run the procedure by simply entering its name. Enter the pathname if the procedure file is not
in your current directory.

The following is a simple shell procedure named lss that sorts ls -l command output by file
size.

Table 11

explains each line in lss.

# lss: list, sorting by size
ls -l | sort -n +4

Table 11 Description of Example Shell Procedure

Description

Line

Comment line describing the purpose of the procedure.

#lss: list, sorting by size

The shell procedure itself. This procedure lists the files in a directory (ls
-l

). Output from the ls -l command is then piped to the sort command

ls -l | sort -n +4

( | sort -n +4). This command skips over the first four columns of the
ls -l

output, sorts the fifth column (the file size column) numerically,

and writes the lines to the standard output file.

To run the lss procedure, simply enter lss at the command line. Sample system output looks
similar to the following:

$ lss

-rw-rw-rw- 1 larry system 65 Mar 13 14:46 file3

-rw-rw-rw- 1 larry system 75 Mar 13 14:45 file2

-rw-rw-rw- 1 larry system 101 Mar 13 14:44 file1

52

The OSS Shell

Advertising
This manual is related to the following products: