Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux command-file internal command

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

1、cat

Link and display all information in the file

-n: Line number can be displayed when displayed. This line number is only displayed and has nothing to do with the file content.

-E: Displays the line terminator of each line, so the line terminator of text files in Linux is the $character.

-T: Tabs can be displayed

-v: Display other non-printed characters

-A: Show all symbols

2、more/less

More: The same effect as cat is the same, but at this time we can manually flip the screen, more convenient, more: only support backward flip, turn to the end directly exit.

less: Display file information, default does not exit the display, q can exit.

Space: Flip back one screen

b: Flip forward one screen

ENTER: Turn back one line

k: forward one line

/KEYWORD: Find keywords

3、head/tail

head: displays the first few lines of the file, default is 10 lines

head -NUM: Display the first number of lines

tail: Display the last few lines of the file, default is 10 lines

tail -NUM: how many lines after display

-f: View the end of the file without exiting, waiting for new content to be added later. Often used to view log files

4、echo

output information

echo "abc"

###echo "String"| passwd --stdin USERNAME: Use pipes to modify user passwords

5. Input and output redirection

Output redirection:

Overwrite output (overwrites the contents of the original file)

Added output (does not overwrite the contents of the original file)

set -C : Disable overwrite redirection for existing files

set +c : disable the above function

2>: Redirect error output, unable to output correct information

2>>: Error output by appending

&>: Redirect standard output or error output to the same file, real-time overwrite mode

Input redirection: edit mode

Type esc.

3. Last line mode: you must enter the last line mode from edit mode.

Type: OK.

4. Last Line Mode--> Edit Mode

Press esc once or several times.

-------------------------------------------------------------

vim exit file:

1. Close the file in the last line mode

w: save file

Q: Withdrawal

wq: Save and exit

q!:Do not save and exit

w!:doc saving

wq=x Save Exit

2. Exit in edit mode

Capital ZZ: Save Exit

------------------------------------------------------------------

Move cursor under vim (edit mode):

1. Move character by character: h: left

L: Right

j: downward

K: Up

#h: Move #(number) characters

2. Move in words

w: Move the beginning of the next word

e: Move to the end of the current word or the end of the next word

b: Move to the beginning of the current word or the beginning of the previous word

#w: Jump #words at a time.

3. Inline jump

0: Skip to the beginning of the line (absolute beginning of the line)

^: Skip to the beginning of the line of the first non-white space character

$: Absolute End of Line

4. Interline jump

#G: Jump directly to line #.

G: Jump directly to the last line

Jump to the last line mode: directly give the line number, enter.

------------------------------------------------------------------

vim flip screen:

Ctrl+F: Scroll down one screen

Ctrl+B: Turn up one screen

Ctrl+D: Flip down half screen

Ctrl+U: Flip up half screen

---------------------------------------------------------------------

vim Delete characters:

x: Delete a single character where the cursor is located

#x: Delete #characters at cursor position and backward

vim delete command: d

d command used in conjunction with jump command

d$: Delete to end of line.

#d jump character: delete #characters specified by jump character

dd: Delete the row where the current cursor is located

#dd: delete the #line within the line including the cursor

In the last row mode:

startADD,ednADDd

1,10d: delete lines 1 to 10

., 100: Delete the current row to row 100.

. Represents the current row

$: Last line

+#: downward #line

$-10: Last 10 lines

Vim deleted content is saved in the buffer, the last deleted content can be pasted.

------------------------------------------------------------------

vim paste command: p

p (lowercase): If the deleted or copied content is a positive line, paste it below the line where the cursor is located. If

If the copied or deleted content is not the whole line, paste it after the character where the cursor is located.

P (upper case): If the deleted or copied content is the positive line, paste it to the top of the line containing the cursor. If

If the copied or deleted content is not the whole line, paste it before the character where the cursor is located.

vim copy command: y

The same as D.

yy: copy a line

vim delete content first, then convert to input mode:c

C is used as d command

cc: Delete a line and enter input mode.

c$: delete to end of line and enter input mode

------------------------------------------------------------------

Undo editing operation command under vim: u

u: undo the last operation, continuous u command can undo the previous n operations

#u: Undo the last #edits directly

-------------------------------------------------------------------------------------------

vim super find replacement

/PATTERN: Find PATTERN matching options from the beginning of the line down

?PATTERN: Find PATTERN matching options from end of line up

vim find and replace: s

Using the s command in last line mode

Same usage as SED

ADDR1,ADDR2s@PATTERN@string@gibr/> h: Left

L: Right

j: downward

K: Up

#h: Move #(number) characters

2. Move in words

w: Move the beginning of the next word

e: Move to the end of the current word or the end of the next word

b: Move to the beginning of the current word or the beginning of the previous word

#w: Jump #words at a time.

3. Inline jump

0: Skip to the beginning of the line (absolute beginning of the line)

^: Skip to the beginning of the line of the first non-white space character

$: Absolute End of Line

4. Interline jump

#G: Jump directly to line #.

G: Jump directly to the last line

Jump to the last line mode: directly give the line number, enter.

------------------------------------------------------------------

vim flip screen:

Ctrl+F: Scroll down one screen

Ctrl+B: Turn up one screen

Ctrl+D: Flip down half screen

Ctrl+U: Flip up half screen

---------------------------------------------------------------------

vim Delete characters:

x: Delete a single character where the cursor is located

#x: Delete #characters at cursor position and backward

vim delete command: d

d command used in conjunction with jump command

d$: Delete to end of line.

#d jump character: delete #characters specified by jump character

dd: Delete the row where the current cursor is located

#dd: delete the #line within the line including the cursor

In the last row mode:

startADD,ednADDd

1,10d: delete lines 1 to 10

., 100: Delete the current row to row 100.

. Represents the current row

$: Last line

+#: downward #line

$-10: Last 10 lines

Vim deleted content is saved in the buffer, the last deleted content can be pasted.

------------------------------------------------------------------

vim paste command: p

p (lowercase): If the deleted or copied content is a positive line, paste it below the line where the cursor is located. If

If the copied or deleted content is not the whole line, paste it after the character where the cursor is located.

P (upper case): If the deleted or copied content is the positive line, paste it to the top of the line containing the cursor. If

If the copied or deleted content is not the whole line, paste it before the character where the cursor is located.

vim copy command: y

The same as D.

yy: copy a line

vim delete content first, then convert to input mode:c

C is used as d command

cc: Delete a line and enter input mode.

c$: delete to end of line and enter input mode

------------------------------------------------------------------

Undo editing operation command under vim: u

u: undo the last operation, continuous u command can undo the previous n operations

#u: Undo the last #edits directly

-------------------------------------------------------------------------------------------

vim super find replacement

/PATTERN: Find PATTERN matching options from the beginning of the line down

?PATTERN: Find PATTERN matching options from end of line up

vim find and replace: s

Using the s command in last line mode

Same usage as SED

ADDR1,ADDR2s@PATTERN@string@gi

.,$- 1: Current line to last line

1,$means full text

Vim shell interaction

:! COMMAND Enter to view, enter again after viewing, enter vim editing mode.

-------------------------------------------------------------------------------------------

vim advanced topic

1. Display or cancel the row number

:set nu

:set nonu

2, set ignore or case-sensitive

:set ignorecase

:set ic ignore

:set noic

3. Set automatic retraction

:set autoindent

:set ai indented

:set noai

4. Highlight or unhighlight the found text

:set hlsearch Highlight

:set nohlserch Cancel

5. Grammar highlighting

:syntax on Open

:syntax off Close

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report