We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下一行,这样不断重复,直到文件末尾。文件内容并没有 改变,除非你使用重定向存储输出
/
@
#
|
sed -i '3i\this is a insert line' test.txt
sed -i '3a\xxxx' file
HEAD
sed 's/^/HEAD&/g' file
TAIL
sed 's/$/&TAIL/g' file
sed -i s#pattern##g filename
xxx
sed -i '/xxx/d' filename
sed -i '/^xxx/d' filename
n
sed -i 'nd' filename
n ~ m
sed -i 'n,md' filename
sed -i '$d' filename
变量
sed -i "${var1},${var2}d" filename
这里引号必须为双引号
sed -i s#old#new#g filename
1
0
sed -i 's/^1/0/g' filename
\
sed -i #s/\“aab/bbc/g' filenam
<path
path>
sed -i 's/\<path.*\\/path\>/g' *
sed -i s#old#new#g `grep -rl "old" .`
sed -i '/keyword/s/^#//' input.txt
sed -i '/keyword/s/xxx/ooo/' input.txt
用于labelimg pascal voc 标记文件中 去掉 local path
'"$var"'
&
sed -i 's/search_word/insert_word&/' your_file
sed -i 's/search_word/&insert_word/' your_file
sed -n 'N, Xp' file_name
sed -n 'N, $p' file_name
-n 只输出符合条件的行
-n
The text was updated successfully, but these errors were encountered:
junxnone/linuxwiki#2
Sorry, something went wrong.
No branches or pull requests
sed 文件流编辑器
UseCase
/
为分隔符/
时,可以使用@
#
|
作为分隔符插入
sed -i '3i\this is a insert line' test.txt
sed -i '3a\xxxx' file
HEAD
sed 's/^/HEAD&/g' file
TAIL
sed 's/$/&TAIL/g' file
删除
sed -i s#pattern##g filename
xxx
的行sed -i '/xxx/d' filename
xxx
开始的行sed -i '/^xxx/d' filename
n
行sed -i 'nd' filename
n ~ m
行sed -i 'n,md' filename
sed -i '$d' filename
变量
行号sed -i "${var1},${var2}d" filename
替换
sed -i s#old#new#g filename
1
开头的字符串 为0
sed -i 's/^1/0/g' filename
\
转义sed -i #s/\“aab/bbc/g' filenam
<path
开头,任意字符后跟着\
的字符串为path>
sed -i 's/\<path.*\\/path\>/g' *
sed -i s#old#new#g `grep -rl "old" .`
#
sed -i '/keyword/s/^#//' input.txt
xxx
sed -i '/keyword/s/xxx/ooo/' input.txt
sed 使用变量
在指定字符前后添加内容
&
代指 搜索关键字位置sed -i 's/search_word/insert_word&/' your_file
sed -i 's/search_word/&insert_word/' your_file
取文件中某行的内容
Reference
The text was updated successfully, but these errors were encountered: