Linux學習隨筆

2022-04-13 07:40:01 字數 939 閱讀 6583

2.echo -e "you should input 2 numbers, i will cross them! \n"

read -p "first number: " firstnu

echo -e:

-e     enable interpretation of backslash escapes

-e加上後\起到轉義作用,比如\n代表回車

read -p "提示字元 " var

3.計算+-x / %:

var=$((運算內容))

[root@www scripts]# echo $(( 13 % 3 ))

4.當子程式完成後,在子程式內的各項變數或動作將會結束而不會傳回到父程式中,這和函式呼叫中的區域性變數相似。

5.

:sp 檔名

如果不輸入檔名,則另開乙個當前文件。

文件間的切換:

ctrl+w+w或者ctrl+w+(j / k)

gg:去到文件頂部

g:去到文件底部

0(數字0):去到當前行的行首

$:去到當前行的行尾

6.指令之後帶有選項與引數:

shell script 的預設變數($0, $1...),(可以對比windows下的帶引數的控制台程式)

/path/to/scriptname  opt1  opt2  opt3  opt4 

$0 $1 $2 $3 $4

這樣夠清楚了吧?執行的指令碼檔名為 $0 這個變數,第乙個接的引數就是 $1 啊~所以,只要我們在 script 裡面善用 $1 的話,就可以很簡單的立即下達某些命令功能了!除了這些數字的變數之外,我們還有一些較為特殊的變數可以在 script 內使用來呼叫這些引數喔!

《鳥哥》

Linux學習隨筆

2.echo e you should input 2 numbers,i will cross them n read p first number firstnu echo e e enable interpretation of backslash escapes e加上後 起到轉義作用,比如...

Linux學習隨筆

cat proc cpuinfo 列印cpu的相關資訊 cat proc meminfo 列印cpu記憶體的相關資訊 cat proc meminfo grep name 輸出cpu記憶體的相關資訊,且篩選只包含name的部分 command1 command2 command1 command2 ...

Linux學習隨筆

mariadb 首先配置允許訪問的使用者,採用授權的方式給使用者許可權。並且重新整理許可權配置使其生效 grant all privileges on to root identified by 123456 with grant option flush privileges 關閉遠端連線功能,只...