In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
The Shell function writes the command sequence together in format to facilitate the repeated use of the command sequence Shell function to define the method function name of the calling function [parameter 1] [parameter 2] instance 1 two numeric summation through sum () {} define function #! / bin/bashsum () {s = `expr $1 + $2 `expr $s} sum 2 3echo $?
#! / bin/bashsum () {s = `expr $1 + $2 `expr $s} res= `expr $(sum 2 3)\ * 2`echo $?, $res
Custom function #! / bin/bash# Custom function service_index () {echo "servicectl" return 1} service_version () {grep "CentOS.*release 7." / etc/centos-release > / dev/null & & echo "centos7" grep "CentOS.*release 6." / etc/centos-release > / dev/null & & echo "centos6" grep "CentOS.*release 5." / etc/centos-release > / dev/null & echo "centos5"} # calls the first two functions servicectl () {[- z $1 | |-z $2]] & & service_index [$(service_version) = "centos7"] & & systemctl $2 ${1} .service | | service $1 $2} [root@localhost ~] # source demo02.sh [root@localhost ~] # servicectl httpd startshell array application scenario includes obtaining array length, obtaining element length, traversing element slices. Element replacement element deletion. Array definition method-array name = (value0 value1 value2...) Method binary array name = ([0] = value [1] = value [2] = value...) Method three list name = "value0 value1 value2..." Array name = ($list name) method four array name [0] = "value" array included data type numeric type character type using "" or''definition to get array length ${array name [@ or *]} # read a subscript assignment ${array name [subscript]} array traversal instance 1 output result #! / bin/bashnum= (11 22 33 44 55) for in the array
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.