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

Basic knowledge of shell

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

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

Self-built calibration time yum install-y ntp uses ntpdate time.fudan.edu.cn to calibrate time

Some of the most common uses of date in scripts:

Date +% F xxxx-xx-xx

Date +% T xx:xx:xx

Date +% Y prints the year in four-digit format

Date +% y prints the year in two-digit format

Date +% m month

Date + d date

Date +% H hours

Date +% M minutes

Date +% S seconds

Date +% s timestamp

Date +% w week, if the result shows 0, it means Sunday

Sometimes a day's date is used in the script: date-d "- 2 days" +% F

Define the format of the variable as the variable name = the value of the variable. You need to add the'$'symbol when referencing the variable in the script, which is consistent with the custom variable described earlier in shell.

Mathematical calculations should be enclosed in [] and with a'$'on the outside.

-lt (less than),-gt (greater than),-le (less than or equal to),-ge (greater than or equal to),-eq (equal to),-ne (not equal).

Read-p "Please input a number:" x

Read-p "Please input another number:" y

Sum=$ [$xylene roomy]

Echo "The sum of the two numbers is: $sum"

The read command is used in such a place to interact with the user, taking the string entered by the user as the value of the variable. The script execution process is as follows:

There is a $0, but it represents the name of the script itself.

If judgment statement; then

Command

Fi

If judgment statement; then

Command

Else

Command

Fi

(a) appears in if1.sh

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

Network Security

Wechat

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

12
Report