pbcopy Command Cat Command locate command find command grep command tar command sed command shutdown command awk programming records and domain concepts commonly used
This article will not be introduced for commands that are too basic for LS,CD. pbcopy Command
Copy to the pasteboard.
In the SSH, you need to copy the public key, here Linux has a command, you can try,
Pbcopy < ~/.ssh/id_rsa.pub
This command also applies to copying files. Cat Command
There are three major functions:
1. Display the entire file at once. Catfilename2. Create a file from the keyboard. Cat filename 2. Create a file from the keyboard. Cat > FileName
You can only create new files, and you cannot edit existing files.
3. Merging several files into one file: $cat file1 file2 > file
Refer to Cat resources.
by command
Ls-l | Cat >file
You can save the results of ls-l to file files.
What is the difference between the Q:cat command and the more command.
(1) Cat role is: To connect and display information about one or more files
How to use: Cat file
-N: Line number numbering for all outputs starting at line 1th
-B: Same as-n but not numbered for blank lines
(2) More role is: similar to cat, but will be a page of the display to facilitate the user page to read
How to use: More file name
Example: more-s testfile displays testfile content on a per-page basis, with two consecutive lines or more blank lines showing in one blank row
More +30 testfile show testfile content starting from line 30th
Copy files Of course can also use CP file1 file2. Changing the filename can be file2 with MV File1. Locate Command
The locate command is used to locate files, which are faster than the Find command, and require a database that is established by routine work (crontab) procedures on a daily basis. Once we have established this database, we can easily search for the required files.
That is, run first: updatedb (either in that directory, can be placed in crontab), the SLOCATE.DB database can be quickly found under/var/lib/slocate/. Execute the #updatedb command directly from the command prompt:
Some students may encounter such a problem:
Updatedb:can not open a temporary the file for '/var/lib/mlocate/mlocate.db '
Solution: With root permission, Su can be. Find Command
A big difference between find and locate commands is that finding is a real-time lookup and locate is not a real-time lookup because the database needs to be updated. But find's search function is very powerful. Not only can find a specific time to modify the file, can also be based on the keyword lookup, can also be based on the file to the user to find, powerful.
This only describes how to find the keyword.
Find. -name "*.sh"
For a good introduction to the Find command, see blog post. Linux Find Search command usage. grep Command
grep is a Linux text Search tool that uses regular expressions to search for text. The grep full name global Regular Expression Print, which represents the global regular expression print.
First we have to build a test text, I found an English article from a VOA website, and copied it into the text as a test text.
Command
grep --color hel*o test.txt
The grep statement matches to the Helo,hello,helllo,hellllo ...
The text is searched according to the rules of the regular expression.
About the grep command, refer to Bowen daily one Linux command (PER): grep command tar command
(1) Commonly used decompression commands, depending on the compressed file, the parameters are different. As follows.
1). Extract the Tar pack
TAR–XVF File.tar
2). Decompression tar.gz
TAR-XZVF file.tar.gz
3). Decompression tar.bz2
TAR-XJVF file.tar.bz2
4). Extract tar. Z
TAR–XZVF File.tar.z
(2) The command to compress files
TAR–CVF Doc.tar *.doc
Pack all doc files in the directory into Doc.tar
TAR–CZF doc.tar.gz *.doc
TAR–CJF doc.tar.bz2 *.doc
TAR–XZVF Doc.tar.z *.doc
All of the above commands can be packaged into different types of compression packs.
Refer to the TAR Compression decompression command. sed command
Sed is an online editor that processes data by behavior units, and can add, replace, and delete data. Common options:
-N: Use Quiet (silent) mode. In general sed usage, all data from stdin is generally listed on the screen. However, if you add the-n parameter, only the line (or action) that is specifically handled by SED will be listed.
Common commands:
A: New
C: Replace
D: Delete
I: Insert, the back of I can connect string
P: Print
The content here comes from the SED usage of Cnbolgs blog Linux.
Here is no longer an example, you can refer to other blogs. The main point is that the SED changes will not work in the original text, which is equivalent to read out after the operation, which need attention. So how does the content after sed be saved? Then use the following command.
Sed ' 1a mapeiwen ' Test.txt|cat >temp.txt
Examples (the title comes from "Linux Shell from Getting started to proficient"): Using the SED command to modify the \ou string in the input file to (OU), the SED command is written in two sed scripts, using SED's 2nd, 3 invocation methods to achieve the same goal.
Answer:
(1) SED ' s/\ou/(ou)/g ' input//\ou escape character
(2) write the SED command into the bash script (#!/bin/bash);
(3) write to sed script (#!/bin/sed-f) shutdown command
sudo shutdown-r now
sudo halt
You can turn off the computer after you enter a password. awk Programming
Awk is a programming language in Linux that is suitable for text processing and report generation. It has a powerful text analysis tool that is particularly powerful when it comes to analyzing and generating reports on data, compared to grep lookup, and sed editing. In short, awk is the reading of the file line by row (record), cutting each record into fields with a blank space as the default separator. Then select the processing for each domain. concepts of records and domains
Awk thinks that the input file is structured (and the structure of the database is in fact almost the same meaning), awk defines each file row as a record, each string in the row is defined as a field, the fields are separated by spaces, tabs, or other symbols, and the symbol for the split field is called the separator.
(from the Linux Shell from getting started to mastering) Common use
(1) According to each article carries on the processing. Some common statistics (often used in data mining)
For example, the data information is as follows (learn number name Chinese mathematics English):
MPW 100 89 81
9 198 78 HHH
Find out the average score for each student.
Find the students with the highest average score.
...
To put it this way, students who have studied junit should know that JUnit 4 has before and after these 2 kinds of adornments. Here the begin and end functions are similar, before the records are traversed to perform the begin, traversing the record to execute the ends. Here the begin and end are case-sensitive (pro-test).
This blog will be constantly updated, perfect ~ ~ ~ Every day to lose a drop slightly. ==