Linux shell指令碼上引 單引 模式匹配

2022-09-04 11:33:07 字數 401 閱讀 6344

生成日期日誌,記錄前一天使用的命令

vim mylog.sh

#!bin/bash

[ -f record ] ||touch record; sed -n '1p' student.txt|awk''>record

start=$(cat record)

mydate=$(date+%y%m%d)

sed -n '/'$start'/,$p' student.txt >$mydate.log

sed -n '$p' student.txt|awk ''>record

··:上引號,命令替換,命令替換是指shell能夠將乙個命令的標準輸出插入在乙個命令列中任何位置

'':單引號,原樣輸出

"":雙引號,取值輸出

//:模式匹配

linux shell中雙引號,單引號,反單引號

shell中的這三個引號容易混淆。雙引號仍然可以保有變數的內容,但單引號僅能是一般字元,而不會有特殊符號 比如,如果雙引號中存在變數,則會在雙引號中將該變數在原地展開,而單引號不會將其作為變數,而是將其作為普通的字元 例 root lufubo centos kernel name lufubo r...

Linux Shell指令碼基礎

shell指令碼在處理自動迴圈或大的任務方面可節省大量時間,且功能強大。任何指令碼都可能有注釋,加注釋需要此行的第乙個字元為 直譯器對此行不予解釋。指令碼不是複雜的程式,它是按行解釋的。指令碼第一行總是以 bin sh開始,這段指令碼通知shell使用系統上的 bourne shell直譯器。指令碼...

linux shell指令碼犯錯

指令碼裡犯了錯 oracle it shell value 1 oracle it shell value 1 bash value command not found oracle it shell value 3 bash value command not found oracle it sh...