File View

Directory Structure

Directory management command
pwd Display the absolute path of the current directory
cd Switch directory
ls View the contents of the directory
-a Display all files, including hidden files (files beginning with .)
-A Display all files, but not display. And...
-R Recursive display All contents and subdirectories under the directory
-l show detailed information
ls -a -l == ls -al == ls -la

-h displays the file size in the closest unit, usually combined with -l
ls -lh == ls -l -h

mkdir to create a directory
Basic usage: mkdir directory name
-p: recursive creation (if there are multiple directories, it will be created layer by layer)
-v: display process

rmdir Delete empty directory
Tab key
Completion command
Start with the character string given by the user and search for the corresponding command at the beginning.
If there is a unique match, just complete
it directly. Otherwise, press the tab key again to give a list. The
completion path
is the character given by the user At the beginning of the string, search for the file or directory that corresponds to the beginning.
If there is a unique match, just complete
it. Otherwise, press Tab again to give a list

The file viewing command
cat connects the file and prints it to the output device (display).
Syntax
cat [option] file name
cat [option] file name 1 file name 2
-n display line number
-b display line number (no blank line displayed)
-E show a terminator "$" at the end of each row
tac: reverse display file
more: View more content files, paging show
an example: more / etc / passwd
shortcut keys:
space to turn a
carriage return line turn
turn Exit automatically at the end
Press q to exit midway

less: page up and down to display files
Example: less /etc/passwd
Shortcut key:
Space to turn down one page,
Enter to turn down one line
Pageup (PgUp) to turn up one page
You can also use the up, down, left, and right direction keys
to exit halfway by pressing q

head Display the first n lines of the file, the default is 10 lines
head [Option] File name
-nx or -x View the first x lines

tail displays the last n lines of the file, the default is 10 lines
tail [Option] File name
-nx or -x: view the last x lines

File operation command
touch creates an empty file
touch file name
cp copy file (copy)
cp [options] source file target file
-v display process
-r recursive copy, used to copy directories

mv move or rename the file (move)
mv [options] source file target file
-v display process

rm delete files or directories (remove)
rm [options] file name/directory name
-f force deletion, no prompt y/n
-r recursive deletion, used to delete the directory
-v display process

Text editor
vi/vim: is a modular editor
vi/vim has three modes.
Command mode (editing mode)
enters the default mode of the vim editor. You can move the mouse, copy yy, paste p, etc.
through a, i, oEnter the input mode. The
input mode is
used to enter the text, press ESC to return to the command mode.
Last line mode
Enter in the command mode: enter the last line mode, and can perform operations such as save (w) and exit (q)

File processing command
tr replace
wc statistics
cut intercept
sort sort
uniq de-
duplicate cut: extract the content of the specified field in the file
cut [options] file name
-d: specify the separator
-f: specify the field to be extracted

Sort sort is
similar to the order by
syntax in SQL
sort [Options] File name
The first character of each line is sorted by default. If the first character is the same, it will be sorted according to the second character, and so on

-r Output sort results in reverse order, similar to desc in SQL
-t specify separator
-k specify the column to be sorted
-n sort according to numerical value
-u remove duplicate rows

uniq Report or ignore repeated lines
uniq [Options] File name
-c Display the number of repeated occurrences of each line
-i Ignore case
-d Only display repeated lines
-u Only display non-repeated lines
tr Replace, compress and delete character commands
tr [Options] Characters to be replaced New characters
wc Statistics
-l line number

Guess you like

Origin blog.csdn.net/weixin_51014063/article/details/108730989