要将前导空格和制表符转换为制表符,存在一个名为 未扩展 命令
null
这个 未扩展 命令默认情况下将每个空格转换为制表符,将生成的输出写入标准输出。以下是unexpand命令的语法: 语法:
$unexpand [OPTION]... [FILE]...
其中,OPTION指与unexpand兼容的选项,FILE指文件名。
使用unexpand命令
将文件中的所有空格字符转换为制表符的步骤 kt。txt 使用 未扩展 作为:
$cat -vet kt.txthave a nice day$always try harder$to achieve better$/* In the below output $ refers to the new line feed and ^I refers to the tab */$unexpand kt.txthave^Ia^Inice^Iday$always^Itry^Iharder$to^Iachieve^Ibetter$
为了将unexpand命令生成的输出保存到另一个文件中 dv。txt 使用以下语法:
/* Saving output in file, dv.txt */$unexpand kt.txt>dv.txt$cat -vet dv.txthave^Ia^Inice^Iday$always^Itry^Iharder$to^Iachieve^Ibetter$
unexpand命令的选项
- -a、 –所有选项: 此选项用于转换所有空格,而不仅仅是初始空格(默认情况下)。
/* This converts all the blanks also into tabs */$unexpand -a kt.txt>dv.txt
- ––第一选项: 这仅用于转换空白的前导序列(覆盖-一个选项)。
/* This converts only the leading sequences of blanks */$unexpand --first-only kt.txt>dv.txt
- -t、 –-tabs=N选项: 该设置将N个字符分开,而不是默认的8个字符(启用-a选项)。
/* the -t option with numerical value 2 forces to change the spaces into tabs of only 2 characters */$unexpand -t2 kt.txt>dv.txt
- -t、 –-tabs=列表选项: 此选项使用逗号分隔的制表符位置列表(启用-a选项)。
- –帮助选项: 这将显示一条帮助消息并退出。
- -版本选项: 这将显示版本信息并退出。
另见: 展开命令
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END