终端 - 在PATH中显示目录,每行一个sed和bash3.X`here string'

另一种方法:awk'{gsub(/:/,“\ n”); print}'
.

0

linux命令:sed 's/:/\n/g' <<<$PATH <<<$PATH 's/:/\n/g' sed sed 's/:/\n/g' <<<$PATHrootopen.com
linux命令:sed 's/:/\n/g' <<<$PATH <<<$PATH 's/:/\n/g' sed sed 's/:/\n/g' <<<$PATHrootopen.com
wrmj 2018-04-16 13:06:48
输出
linux命令:sed 详解
替代方案1 终端 - 在PATH中显示目录,每行一个sed和bash3.X`here string'

.

linux命令:tr : '\n' <<<$PATH <<<$PATH '\n' : tr tr : '\n' <<<$PATHrootopen.com
linux命令:tr : '\n' <<<$PATH <<<$PATH '\n' : tr tr : '\n' <<<$PATHrootopen.com
.
输出

评论

相关推荐

命令将打印指定文件的第101行和第106行。 -n默认情况下,将使sed不打印所有行。 该-e是指定一个sed命令,你可以一次多次使用它。

linux命令:sed -ne '101 p' -e '106 p' /path/to/the/file /path/to/the/file p' '106 -e p' '101 -ne sed sed -ne '101 p' -e '106 p' /path/to/the/filerootopen.com
linux命令:sed -ne '101 p' -e '106 p' /path/to/the/file /path/to/the/file p' '106 -e p' '101 -ne sed sed -ne '101 p' -e '106 p' /path/to/the/filerootopen.com
.

删除文件中的\ r \ n(回车)

linux命令:sed -i 's/\r//g somefile.txt somefile.txt 's/\r//g -i sed sed -i 's/\r//g somefile.txtrootopen.com
linux命令:sed -i 's/\r//g somefile.txt somefile.txt 's/\r//g -i sed sed -i 's/\r//g somefile.txtrootopen.com
.

转义引号,从JSON中删除换行符,制表符和空格

linux命令:sed 's / \“/ \\\”/ g'json_file | tr -d '\ n' | tr -d '[[:blank:]]' '[[:blank:]]' -d tr | n' '\ -d tr | g'json_file \\\”/ \“/ / 's sed sed 's / \“/ \\\”/ g'json_file | tr -d '\ n' | tr -d '[[:blank:]]'rootopen.com
linux命令:sed 's / \“/ \\\”/ g'json_file | tr -d '\ n' | tr -d '[[:blank:]]' '[[:blank:]]' -d tr | n' '\ -d tr | g'json_file \\\”/ \“/ / 's sed sed 's / \“/ \\\”/ g'json_file | tr -d '\ n' | tr -d '[[:blank:]]'rootopen.com
.

linux命令:sed -e 's/ *$//' ~/.bash_history | sort | uniq -cd | sort -nr | head head | -nr sort | -cd uniq | sort | ~/.bash_history *$//' 's/ -e sed sed -e 's/ *$//' ~/.bash_history | sort | uniq -cd | sort -nr | headrootopen.com
linux命令:sed -e 's/ *$//' ~/.bash_history | sort | uniq -cd | sort -nr | head head | -nr sort | -cd uniq | sort | ~/.bash_history *$//' 's/ -e sed sed -e 's/ *$//' ~/.bash_history | sort | uniq -cd | sort -nr | headrootopen.com
.

Sed在比赛中停止解析,因此比管道尾部或类似物更有效。使用'999995,1000005!d'<my_massive_file获取一行范围

linux命令:sed '1000000!d;q' < massive-log-file.log massive-log-file.log < '1000000!d;q' sed sed '1000000!d;q' < massive-log-file.logrootopen.com
linux命令:sed '1000000!d;q' < massive-log-file.log massive-log-file.log < '1000000!d;q' sed sed '1000000!d;q' < massive-log-file.logrootopen.com
.

linux命令:sed -e '/^[<space><tab>]*$/d' somefile somefile '/^[<space><tab>]*$/d' -e sed sed -e '/^[<space><tab>]*$/d' somefilerootopen.com
linux命令:sed -e '/^[<space><tab>]*$/d' somefile somefile '/^[<space><tab>]*$/d' -e sed sed -e '/^[<space><tab>]*$/d' somefilerootopen.com
.

从Cisco配置中为John the Ripper设置密码文件(级别5)从http://www.openwall.com/lists/john-users/2006/05/14/8

linux命令:sed -n 's/[ :]/_/g; s/^\(.\{1,\}\)_5_\($1$[$./0-9A-Za-z]\{27,31\}\)_*$/\1:\2/p' < cisco-device-config > passwd passwd > cisco-device-config < s/^\(.\{1,\}\)_5_\($1$[$./0-9A-Za-z]\{27,31\}\)_*$/\1:\2/p' :]/_/g; 's/[ -n sed sed -n 's/[ :]/_/g; s/^\(.\{1,\}\)_5_\($1$[$./0-9A-Za-z]\{27,31\}\)_*$/\1:\2/p' < cisco-device-config > passwdrootopen.com
linux命令:sed -n 's/[ :]/_/g; s/^\(.\{1,\}\)_5_\($1$[$./0-9A-Za-z]\{27,31\}\)_*$/\1:\2/p' < cisco-device-config > passwd passwd > cisco-device-config < s/^\(.\{1,\}\)_5_\($1$[$./0-9A-Za-z]\{27,31\}\)_*$/\1:\2/p' :]/_/g; 's/[ -n sed sed -n 's/[ :]/_/g; s/^\(.\{1,\}\)_5_\($1$[$./0-9A-Za-z]\{27,31\}\)_*$/\1:\2/p' < cisco-device-config > passwdrootopen.com
.

非常快速地更改文件中的单词。我一直用它来改变PHP脚本中的变量名(sed -i's / $ oldvar / $ newvar / g'index.php)

linux命令:sed -i 's/OLD/NEW/g' FILE FILE 's/OLD/NEW/g' -i sed sed -i 's/OLD/NEW/g' FILErootopen.com
linux命令:sed -i 's/OLD/NEW/g' FILE FILE 's/OLD/NEW/g' -i sed sed -i 's/OLD/NEW/g' FILErootopen.com
.

原位搜索替换,但留下了有日期戳的备份。更精确的变体:sed -i.`date +%Y%m%d%H%M%S'/ pattern / replace'[文件名]

linux命令:sed -i.`date +%Y%m%d` -e 's/pattern/replace' [filename] [filename] 's/pattern/replace' -e +%Y%m%d` -i.`date sed sed -i.`date +%Y%m%d` -e 's/pattern/replace' [filename]rootopen.com
linux命令:sed -i.`date +%Y%m%d` -e 's/pattern/replace' [filename] [filename] 's/pattern/replace' -e +%Y%m%d` -i.`date sed sed -i.`date +%Y%m%d` -e 's/pattern/replace' [filename]rootopen.com
.

如果文件内容是:-blah blah blahABChello等等等等等等等等等,你会得到:-ABChello等等等等等等等等等blohDEF

linux命令:sed "s/^ABC/+ABC/" <file | sed "s/DEF$/DEF+/" | tr "\n" "~" | tr "+" "\n" | grep "^ABC" | tr "~" "\n" "\n" "~" tr | "^ABC" grep | "\n" "+" tr | "~" "\n" tr | "s/DEF$/DEF+/" sed | <file "s/^ABC/+ABC/" sed sed "s/^ABC/+ABC/" <file | sed "s/DEF$/DEF+/" | tr "\n" "~" | tr "+" "\n" | grep "^ABC" | tr "~" "\n"rootopen.com
linux命令:sed "s/^ABC/+ABC/" <file | sed "s/DEF$/DEF+/" | tr "\n" "~" | tr "+" "\n" | grep "^ABC" | tr "~" "\n" "\n" "~" tr | "^ABC" grep | "\n" "+" tr | "~" "\n" tr | "s/DEF$/DEF+/" sed | <file "s/^ABC/+ABC/" sed sed "s/^ABC/+ABC/" <file | sed "s/DEF$/DEF+/" | tr "\n" "~" | tr "+" "\n" | grep "^ABC" | tr "~" "\n"rootopen.com
.

linux命令:sed -e :a -e '/$/N;s/\n/ /;ta' <filename> <filename> /;ta' '/$/N;s/\n/ -e :a -e sed sed -e :a -e '/$/N;s/\n/ /;ta' <filename>rootopen.com
linux命令:sed -e :a -e '/$/N;s/\n/ /;ta' <filename> <filename> /;ta' '/$/N;s/\n/ -e :a -e sed sed -e :a -e '/$/N;s/\n/ /;ta' <filename>rootopen.com
.

特别感谢XwZ :)

linux命令:sed -e "/$USER/d;s/:.*//g" /etc/group | sed -e :a -e '/$/N;s/\n/ /;ta' /;ta' '/$/N;s/\n/ -e :a -e sed | /etc/group "/$USER/d;s/:.*//g" -e sed sed -e "/$USER/d;s/:.*//g" /etc/group | sed -e :a -e '/$/N;s/\n/ /;ta'rootopen.com
linux命令:sed -e "/$USER/d;s/:.*//g" /etc/group | sed -e :a -e '/$/N;s/\n/ /;ta' /;ta' '/$/N;s/\n/ -e :a -e sed | /etc/group "/$USER/d;s/:.*//g" -e sed sed -e "/$USER/d;s/:.*//g" /etc/group | sed -e :a -e '/$/N;s/\n/ /;ta'rootopen.com
.

当主机的ssh密钥发生变化并且ssh拒绝连接到机器时,它非常有用,同时给你在〜/ .ssh / known_hosts中更改的行号。

linux命令:sed -i '10d' <somefile> <somefile> '10d' -i sed sed -i '10d' <somefile>rootopen.com
linux命令:sed -i '10d' <somefile> <somefile> '10d' -i sed sed -i '10d' <somefile>rootopen.com
.

linux命令:sed 's/$'"/`echo \\\r`/" \\\r`/" 's/$'"/`echo sed sed 's/$'"/`echo \\\r`/"rootopen.com
linux命令:sed 's/$'"/`echo \\\r`/" \\\r`/" 's/$'"/`echo sed sed 's/$'"/`echo \\\r`/"rootopen.com
.

删除前55行;将55改为任意数字

linux命令:sed '1,55d' '1,55d' sed sed '1,55d'rootopen.com
linux命令:sed '1,55d' '1,55d' sed sed '1,55d'rootopen.com
.

linux命令:sed '/./,$!d' '/./,$!d' sed sed '/./,$!d'rootopen.com
linux命令:sed '/./,$!d' '/./,$!d' sed sed '/./,$!d'rootopen.com
.

ctrl + v,ctrl + m部分表示您应该执行的按键操作。如果你成功地做到了,你会看到一个^ M字符出现。

linux命令:sed 's/$/<ctrl+v><ctrl+m>/' 's/$/<ctrl+v><ctrl+m>/' sed sed 's/$/<ctrl+v><ctrl+m>/'rootopen.com
linux命令:sed 's/$/<ctrl+v><ctrl+m>/' 's/$/<ctrl+v><ctrl+m>/' sed sed 's/$/<ctrl+v><ctrl+m>/'rootopen.com
.

linux命令:sed 's/$//' 's/$//' sed sed 's/$//'rootopen.com
linux命令:sed 's/$//' 's/$//' sed sed 's/$//'rootopen.com
.

linux命令:sed '1!G;h;$!d' '1!G;h;$!d' sed sed '1!G;h;$!d'rootopen.com
linux命令:sed '1!G;h;$!d' '1!G;h;$!d' sed sed '1!G;h;$!d'rootopen.com
.

我有时会在文件中存储大量的MAC地址文件,有些数据库需要使用分号存储的信息(使设备更容易编程),而其他数据库则不需要。 awk'{for(i = 10; i> = 2; i- = 2)$ 0 = substr()我有一个条形码文本文件扫描器,通常屠杀MAC地址,所以这是修复> $ 0,1,i)“:”substr($ 0,i + 1); print}'mac_address_list

linux命令:sed 's/\(..\)/\1:/g;s/:$//' mac_address_list mac_address_list 's/\(..\)/\1:/g;s/:$//' sed sed 's/\(..\)/\1:/g;s/:$//' mac_address_listrootopen.com
linux命令:sed 's/\(..\)/\1:/g;s/:$//' mac_address_list mac_address_list 's/\(..\)/\1:/g;s/:$//' sed sed 's/\(..\)/\1:/g;s/:$//' mac_address_listrootopen.com
.
共收录0条命令行
这里是记录和分享命令行的地方, 所有命令行都可以进行评论、提交替代方案.

推荐
    热门命令