Some text processing tools for Linux

Some text under the heading Linux viewer and text processing tool (1, cat and tac)

There are a lot of Linux, text viewer, text processing tool, why should it be divided into two categories? Because the view is to look at, not to make changes to text, text processing tools can be for this change. Two types of tools is very close contact, due to a major feature of Linux systems, pipeline operators, making our work more diversity. (Different commands or tools feature-rich produce pipe character, as if, like a chemical reaction, intoxicated) Here's a preliminary understanding of the text under the viewing process tool.
1cat and tac command, two commands are twins command with a positive reading text, is the opposite of a read text
such as:

  cat /etc/fstab
  tac /etc/fstab
  当然,这两个命令不是按字符显示,是按行显示,
  也就是说tac是反转行间内容。
``

Looks like the first time to see, feel this cat text commands are also very common, like no big deal, you're wrong, this command is very common, very important.

cat >file1
echo "helo,XXX"
#这时,按Ctrl+c退出编写,在cat,
cat file1
#这时,你会发现echo的内容在file1这个文件里了,如果想
#在这个文件里追加内容,
cat >>file1
这是我要追加的内容?
#再次按Ctrl+c, 这时在查看文件内容,你会发现 
#多出了上面的那句话。也就是说,可以看空哦。
#这在你不想打开vim或者vi编写简单的脚本文件时,很方便。
#cat命令还可以看Linux下的一个特殊文件,
#/dev/urandom,这个是生成随机的字符,利用这个我们可以
#得到随机的想要的长度的字符作为自己的密码。
#例如,想要生成一个长度为十的密码,这个密码不带特殊符号,
#那么,我们需要cat命令和别的命令通过管道符来实现这个目
#的。下面上代码:
cat -n /dev/urandom | tr -dc 'a-zA-Z0-9' |head -c 10
#这个命令就可以当做一个简单的密码生成器了,如果想保存这个
#密码,如上,通过重定向符追加到文本文档内,如果想使用生成的
#密码在用户管理上,通过管道符追加到passwd命令内即可。如果,
#想要定期给用户更换密码,将前述命令加入计划服务内即可


In fact, cat command itself is not a very powerful tool for viewing text, but with the pipe character oriented character, you can achieve a variety of functions, the order is worth learning.

Published 13 original articles · won praise 0 · Views 302

Guess you like

Origin blog.csdn.net/alwaysbefine/article/details/104793720