Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Combing the basic knowledge of shell script & lt; + & gt;: Array

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Array definition

Static definition: array= (1 2 3)

Dynamic definition: array= ($(ls))

Array assignment: array [3] = 4

Print array

Echo ${array [0]} print array elements with ${array name [subscript]} subscript starting at 0

Echo ${array []} subscript is or @ to get the contents of the entire array

Echo ${# array [@]} get the array length

Check whether multiple website addresses are normal in batch.

Requirements: shell array method implementation, detection strategy as far as possible to simulate user access ideas

Http://www.wewe.org

Http://www.tbibib.com

Http://werrfd.com

Http://192.168.0.7

Script

#! / bin/bash

[- f / etc/init.d/functions] & &. / etc/init.d/functions

Array= (

Http://www.wewe.org

Http://www.tbibib.com

Http://werrfd.com

Http://192.168.0.7

)

Wait () {

Echo-n "wait 3s"

For ((iThin0inction iUniverse devUniverse null)

RETVAL=$?

If [$RETVAL-eq 0]; then

Action "check $1" / bin/true

Else

Action "check $1" / bin/false

Fi

Return $RETVAL

}

Main () {wait

For ((iwait)

For ((iSuppli)

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report