[LINUX] Shell script basics # 2

Shell script basics # 2

Function definition format

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

Shell script basics # 2
Shell script command replacement
Shell script special variables
Shell script @ study memo
Let's try a shell script
[Infrastructure] Linux command, shell script collection
Basic syntax notes for shell script
Automate environment construction with Shell Script
Shell script numerical calculation bc command
Python basics ⑤
Linux basics
Python basics
NumPy basics
Python basics ④
Pandas basics
Git basics
[Ubuntu] How to execute a shell script
Python basics ③
Python basics
Django basics
Linux basics
Pandas basics
Manage logrotate generations with a shell script.
Python basics
[Linux] Learn the basics of shell commands
Python basics
Python basics ③
Creating a shell script to write a diary
Python basics ②
Python basics ②
Shell memo
Shell programming
View today's weather forecast with a shell script
Erase & generate serial number files with shell script
Shell script for batch update of pip3 packages
Launch a shell while a Python script is running