# align all text flush right on a 79-column width
#右对齐,按79列宽排列所有文本
sed -e :a -e 's/^.\{1,78\}$/ &/;ta' # set at 78 plus 1 space
t命令的man
If a s/// has done a successful substitution since the last input line was read and since the last t or T command, then branch to label; if label is omitted, branch to end of script.
一个s///命令成功替换后,那就流程就分支到label出,没成功替换就分支到脚本底部。
-e选项 add the script to the commands to be executed
整体语句的逻辑就是循环把有78个字符替换成空格加它们本身(也就是79列)。
# center all text in the middle of 79-column width. In method 1,
# spaces at the beginning of the line are significant, and trailing
# spaces are appended at the end of the line. In method 2, spaces at
# the beginning of the line are discarded in centering the line, and
# no trailing spaces appear at the end of lines.
#使所有文本居于79列宽的格式中央。在第一种方法中,每一行开头处的空格是
#很重要的,最后的空格被附在行尾。第二种方法中,一行开头的空格在中心对
#齐的行中被丢弃,行尾也没有原来结尾处的空格。
sed -e :a -e 's/^.\{1,77\}$/ & /;ta' # method 1
sed -e :a -e 's/^.\{1,77\}$/ &/;ta' -e 's/\(*\)1/\1/' # method 2
这个语句和上面的类似,不再赘述。
分享到:
相关推荐
英文原版《 HANDY ONE-LINERS FOR SED》,都是一些使用sed写单行脚本的技巧!
基本的SED命令基本的SED命令基本的SED命令基本的SED命令基本的SED命令
AWK命令详解 sed命令详解 AWK命令详解 sed命令详 AWK命令详解 sed命令详解解
windows下cmd程序sed命令所需文件,记得配环境变量
Sed命令是linux下的一个非常有用的命令,特别是在shell脚本中经常会使用到他。 熟悉他你会觉得非常有趣哦! 1.sed -n '2'p filename 打印文件的第二行。 2.sed -n '1,3'p filename 打印文件的1到3行 3. sed -n '/...
压缩包里包含有一个word文档,说我平时使用sed命令的记录,一个学习笔记,还有一个sed使用手册。sed是个强大的流编辑器,灵活使用可以减少很多麻烦。
linux sed 命令详解 资源收集 linux sed 命令详解 资源收集
linux sed命令详解
linux命令中Sed各种使用方式
sed one line pdf sed one line pdf sed one line pdf sed one line pdf sed one line pdf
Linux sed命令 Linux 命令大全 Linux 命令大全 Linux sed命令是利用script来处理文本文件。 sed可依照script的指令,来处理、编辑文本文件。 Sed主要用来自动编辑一个或多个文件;简化对文件的反复操作;编写转换...
处理时,把当前处理的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令处理缓冲区中的内容,处理完成后,把缓冲区的内容送往屏幕。接着处理下一行,这样不断重复,直到文件末尾。文件内容并...
Linux sed命令 相关请见资料内 sed awk都有 Linux sed命令 相关请见资料内 sed awk都有
sed操作命令手册.pdf
Shell编程-字符截取命令-sed命令
这意味着您必须将要对数据执行的命令插入到命令行或要处理的脚本中。当显示它时,请忘记您在使用 Microsoft Word 或其它大多数编辑器时拥有的交互式编辑文件功能。sed 在一个文件(或文件集)中非交互式、并且不加...
本文章是关于理解linux流编辑器sed命令。
sed的常用命令大全集合,适用于小白的快速入手。
sed很强大的文本操作命令
shell编程中经常用到sed命令,本文详细介绍了shell常用命令sed详细用法