sed命令詳解 linux
- IT科技
- 關注:2.21W次
sed命令是利用指令碼來處理文字檔案,編輯文字檔案,主要用來自動編輯一個或多個檔案,簡化對檔案的反覆操作,編寫轉換程式等。
語法:sed [-hnV][-e<script>][-f<script檔案>][文字檔案]
參考例子:
一條sed命令,刪除/etc/passwd第三行到末尾的資料,並把bash替換為blueshell
nl /etc/passwd | sed -e '3,$d' -e 's/bash/blueshell/'
1 root:x:0:0:root:/root:/bin/blueshell
2 daemon:x:1:1:daemon:/usr/sbin:/bin/sh
-e表示多點編輯,第一個編輯命令刪除/etc/passwd第三行到末尾的資料,第二條命令搜尋bash替換為blueshell。
引數:
-e<script>或--expression=<script> 以選項中指定的script來處理輸入的文字檔案。
-f<script檔案>或--file=<script檔案> 以選項中指定的script檔案來處理輸入的文字檔案。
-h或--help 顯示幫助。
-n或--quiet或--silent 僅顯示script處理後的結果。
-V或--version 顯示版本資訊。
- 文章版權屬於文章作者所有,轉載請註明 https://shqsg.com/dianzi/1p10pp.html