Archive for the tag 'arguments'

SBDavid

Bash Command line Arguments

Bash Command line Arguments

These are variables that contain the arguments to a script when it is run. These variables are accessed using $1, $2, … $n, where $1 is the first command-line argument, $2 the second, etc. Arguments are delimited by spaces. $0 is the name of the script. The variable $# will display the number of command-line arguments supplied; this number is limited to 9 arguments in the older shells, and is practically unlimited in the modern ones.

Example:

Consider a script that will take two command-line arguments and display them.

#!/bin/sh
echo “The first variable is $1″
echo “The second variable is $2
SBDavid

find command numeric arguments

find command numeric arguments

Numeric arguments can be specified as:

+n for greater than n.

-n for less than n.

n for exactly n.

-amin n

File was last accessed n minutes ago.

-anewer file

File was last accessed more recently than file was modified. If file is a symbolic link and the -H option or the -L option is in effect, the access time of the file it points to is always used.

-atime n

File was last accessed n*24 hours ago. When find figures out how many 24-hour periods ago the file was last accessed, any fractional part is ignored, so to match -atime +1, a file has to have been accessed at least two days ago.

-cmin n

File’s status was last changed n minutes ago.

-cnewer file

File’s status was last changed more recently than file was modified.

-ctime n

File’s status was last changed n*24 hours ago. See the comments for -atime to understand how rounding affects the interpretation of file status change times.