Shell script basics # 2
There are three definitions.
function <Function name> ()
{
processing
}
#Function definition without parentheses
function <Function name>
{
processing
}
#Function definition omitting function
<Function name> ()
{
processing
}
Here is a simple example. The function name is function1 and the process displays the current date.
[wataru@localhost work]$ cat shellTest.sh
#!/bin/bash
function1 ()
{
date
}
function1
[wataru@localhost work]$ ./shellTest.sh
Fri Sep 25 16:46:29 PDT 2020
Recommended Posts