shell——Day3

Sort a.sort

The default sort in ascending order sorted by the first letter of each line of the file (number) of the ASCII table.

[root@lsl ~]# vi b.txt
user1
user2
a
b
1
10
6
11
5
22
c
g
[root @ lsl ~] # sort -n b.txt // input information sorted by the numerical case 
A 
B 
C 
G 
user1 
user2 
. 1 
. 5 
. 6 
10 
. 11 
22 is

Example: dividing the third column passwd directory, a sort p

sort -t ":" -k3 -n /etc/passwd

 As can be seen from the drawing files sorted 012345

 Example: Statistics repetition value and distinct values

vi c.txt // input values and a plurality of duplicate files in a non-duplicate test values 
A 
A 
B 
B 
B 
B 
B 
C 
G 
G 
G
[root @ LSL ~] # the Sort c.txt | uniq -c -d   // duplicate values statistics

 

[root@lsl ~]# sort c.txt | uniq -c -u

Note: sort parameter

-n ordered according to numerical values

-f Ignore the case of letters

-t specify the delimiter (cut-d)

-k taken to specify the column

-u deduplication (consecutive identical values)

 

. B Programming principle:

1, Introduction to Programming

Objective: To allow hardware devices to achieve certain specified function of the human

How to recognize these hardware programming languages

Early language: basic

                  Assembly language

                  Limitations, each manufacturer has its own hardware devices can be recognized by the assembly language format

High-level languages: C ++ C # language C, the Java, Python, Go, perl, shell (humans tend to be able to read and write)

Compile: human able to identify programming language, translated into computer language that can be recognized

Depending on the programming mode is divided into:

1) compiled: compile once, all execution

2) Explanatory: Compile a row, to interpret a line, one line

Program instructions = data +

2, shell scripts Introduction

Advantages: the operating system command instructions

The python advantages: a large number of third-party modules, any function can be realized (the direction of automated operation and maintenance)

shell script the first sentence:

#! / Bin / bash // specify the following explanation of what language do

cat / etc / shells to see which shell procedures

Linux under each program has a user to start

    

 

                  

          

 

Guess you like

Origin www.cnblogs.com/Blockblogs/p/11545393.html