linux 獲取當天生成的檔案

2022-03-20 14:40:41 字數 1703 閱讀 1111

使用function 來獲取

捎帶介紹一下sed命令這兩個選項:

[vmuser@bd-c02 prod]$ vim test.txt

[vmuser@bd-c02 prod]$ cat test.txt

abcd;9527;efg

hello shell

[vmuser@bd-c02 prod]$ sed 's/9527/hello/' test.txt > target.txt 首先sed是有乙個預設輸出的,也就是將所有檔案內容都輸出,加上命令列中的替換,那麼輸出結果就是下面這樣

[vmuser@bd-c02 prod]$ cat target.txt

abcd;hello;efg

1035925174

exit

hello shell

[vmuser@bd-c02 prod]$ sed 's/9527/hello/p' test.txt > target.txt 這行的意思就是:首先sed預設輸出檔案全部內容,然後p又將匹配到的內容列印了一遍,也就是會輸出兩邊匹配到的內容

[vmuser@bd-c02 prod]$ cat target.txt

abcd;hello;efg

abcd;hello;efg

1035925174

exit

hello shell

[vmuser@bd-c02 prod]$ sed -n 's/9527/hello/p' test.txt > target.txt 這行就是sed -n遮蔽預設輸出然後s替換,p再將匹配到的內容列印出來,所以只顯示了一行,也就是匹配到的那一行

[vmuser@bd-c02 prod]$ cat target.txt

abcd;hello;efg

[vmuser@bd-c02 prod]$ sed -n 's/9527/hello/' test.txt > target.txt 這行就是sed -n選項遮蔽預設輸出,s替換,但是沒有p就不會將匹配到的內容輸出

[vmuser@bd-c02 prod]$ cat target.txt

[vmuser@bd-c02 prod]$

linux下apache日誌檔案每天生產乙個

引言 apache預設安裝下,日誌記錄只有乙個檔案,時間久了之後,這個檔案會變的很大,管理員要想檢視分析日誌,光開啟日誌就要花費很長時間,甚至還會影響伺服器執行。下面教大家設定apache,讓伺服器每天單獨生成乙個日誌檔案,這樣管理 分析日誌會方便很多。vi etc httpd conf httpd...

Oracle獲取當天,當月,當年的資料

between to date to char sysdate,yyyy mm dd 00 00 01 yyyy mm dd hh24 mi ss and to date to char sysdate,yyyy mm dd 23 59 59 yyyy mm dd hh24 mi ss oracle...

Nginx 配置按日期每天生成乙個日誌檔案

1.先設個變數 logdate map time iso8601 logdate d d ymd default date not found 上面這段放到 http 塊,我用的寶塔面板,在nginx管理裡修改 2.配置日誌檔案路徑 上面這段放站點設定裡,www wwwlogs cnblogs.co...