Home PC Games Linux Windows Database Network Programming Server Mobile  
  Home \ Linux \ Linux basic introductory tutorial ---- simple text processing     - Nginx1.8 version upgrade method AMH4.2 Free manually compile (Server)

- Linux SU command security Suggestions (Linux)

- Debian 8 (amd64) installation deployment Memcached management tools MemAdmin (Server)

- Servlet life cycle code examples (Programming)

- pkg-config to use (Linux)

- Linux Kernel 4.2.2 compiler installation tutorial (Linux)

- Java application server WildFly (Server)

- How to make a U disk to install Ubuntu (Linux)

- Java concurrent programming using the synchronized keyword ReentrantLock alternative primitive (Programming)

- Linux Firewall Basics (Linux)

- Editor of the popular Linux Gvim (Linux)

- Simple solution CC attack under Linux VPS (Linux)

- Getting Started with Linux system to learn: how to install the kernel headers on Linux (Linux)

- CentOS 6.2 install git error Perl5 (Linux)

- Android custom controls create the simplest skid menu in the history (Programming)

- Install and configure GO 1.2.1 under CentOS 6.5 (Linux)

- The direct insertion sort algorithm (Programming)

- How to use Xmanager Remote Desktop and VNC Log (Linux)

- Linux --- process tracking (Linux)

- OpenGL Superb Learning Notes - Depth Texture and Shadows (Programming)

  Linux basic introductory tutorial ---- simple text processing
  Add Date : 2016-06-28      

In this section we will introduce these orders tr (note not tar), col, join, paste. This section is actually a continuation of the operation of the pipeline can be achieved on command, so we still will combine the pipeline to become familiar with the use of these commands.

A commonly used text processing commands

Second, text processing commands

1.tr command

tr command can be used to delete a text message some text. Or to be converted.


tr [option] ... SET1 [SET2]
Commonly used options are:

Option Description
-d Delete set1 and matching characters, note that not the whole word matching is not match a sequence of characters
-s removed in the input text and continuously repeat a specified character set1

# Delete "hello abcabcabc" all the 'o', 'l', 'h'
$ Echo 'hello abcabcabc' | tr -d 'olh'
# Set "hello" in ll, to a weight of l
$ Echo 'hello' | tr -s 'l'
# Input text to all uppercase or lowercase output
$ Cat / etc / passwd | tr '[: lower:]' '[: upper:]'
# The above '[: lower:]' '[: upper:]' You can simply write '[a-z]' '[A-Z]', of course, in turn, will uppercase lowercase variants are possible

More tr use, you can use the --help or man tr obtained.

2.col command

col command may be replaced by peer Tab number of spaces built or reverse this operation.


col [option]
Commonly used options are:

Option Description
Tab will be converted to spaces -x
-h converting spaces to Tab (default option)

# Check / etc / protocols are invisible characters, you can see a lot of ^ I, which is actually Tab escape into symbols visible characters
$ Cat -A / etc / protocols
# Col -x will use / etc / protocols in Tab converted to spaces, then use cat to view, you find ^ I missing
$ Cat / etc / protocols | col -x | cat -A

3.join command

Learned about this user databases should not be unfamiliar, this command is used contains two files with the same contents of the line combined.


join [option] ... file1 file2
Commonly used options are:

Option Description
-t separator specified, the default is spaces
-i ignore case differences
-1 Indicate which field to use the first file to compare the default contrast ,, the first field
-2 Indicate which field to use the second file to compare the default contrast ,, the first field

# Create two files
$ Echo '1 hello'> file1
$ Echo '1 abcabcabc'> file2
$ Join file1 file2
# The / etc / passwd and / etc / shadow file merge two, in order to specify the ':' as a separator
$ Sudo join -t ':' / etc / passwd / etc / shadow
# The / etc / passwd and / etc / group file merge two, in order to specify the ':' as a separator, respectively, compared to the fourth and three fields
$ Sudo join -t ':' -1 4 / etc / passwd -2 3 / etc / group

4.paste command

paste this command is similar to the join command, which is without comparison data, simply merge multiple files together, separated by Tab.


paste [option] file ...
Commonly used options are:

Option Description
-d delimiter specifies the merger, the default is Tab
-s do not merge into one line, one line per file

$ Echo hello> file1
$ Echo abcabcabc> file2
$ Echo www.abcabcabc.com> file3
$ Paste -d ':' file1 file2 file3
$ Paste -s file1 file2 file3

III Summary

These commands are not above all you will often be used, but they are very useful indeed, after the master, you can reduce a lot of work, such as stop with the mouse to copy and paste an assignment in gedit paste inside, the contents of two files merged into a single file, which had only one command to complete.


1, in the "file packing and decompression," an experiment that is mentioned in Windows / dos and Linux / UNIX text file special character inconsistencies, such as line breaks Windows as CR + LF (\ r \ n), Linux / UNIX to LF (\ n). Use cat -A you can see the text contained in the text invisible special characters. Linux, \ n is a $ manifested, and Windows / dos performance as ^ M $, and can be used directly dos2unix unix2dos tool to convert between the two formats, use the file command to view a specific type of file. But now when you do not want to use the two conversion tools, using the previously learned commands manually dos text format to UNIX text format conversion.

2, also remember as a child playing in the top bully small bee game? It should be the name of the Orthodox Space Invaders: Space Invaders.

Use the following command to install, was called ninvaders because this game is based on ncurses graphics library to do command line:

sudo apt-get install ninvaders
- Vi syntax highlighting settings (Linux)
- CentOS network configuration 7, and set the host name and IP-bound problems (Linux)
- JavaScript: understanding regular expressions (Programming)
- Oracle 11g R2 RAC RMAN backup script example (Database)
- Python system default encoding (Programming)
- C # compiler to achieve functional use in the runtime (Programming)
- Installation of JDK and Tomcat under Linux (CentOS) (Linux)
- Nginx + ownCloud + PHP + MySQL to build personal private cloud under CentOS7 (Server)
- VSFTPD Security (Linux)
- Python: Finding meet the conditions specified in the file directory (Programming)
- Iptables application layer plug (Linux)
- MySQL uses mysqld_multi to deploy stand-alone multi-instance detail procedures (Database)
- CentOS install SVN server configuration and automatically synchronized to the Web directory (Server)
- APF firewall installation and configuration under Linux (Linux)
- Mac OS X Server installation and application (Linux)
- Analytical Ceph: handle network layer (Server)
- Ubuntu Tutorial: How to Upgrade a New Linux Kernel 3.12.7 on Ubuntu (Linux)
- VMware clone Linux find eth0 (Linux)
- Summarize small problems encountered in the use Lua (Programming)
- Five Linux user space debugging tool (Linux)
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.