File operations
CP, MV, RM
Copy command: CP
CP [OPTION] SOURCE DEST
CP SRC DEST
SRC is a file:
If the target does not exist: Creates a new dest and fills the contents of SRC into the dest;
If the directory exists:
If Dest is a file: overwrites the contents of SRC into the dest;
It is recommended to use the-I option for the CP command;
If Dest is a directory: Create a new file with the same name as the original file under Dest, and populate the contents of SRC with the new file;
CP SRC ... DEST
Src... : Multiple Files
Dest must exist and be directory, other situations will be error;
CP SRC DEST
SRC is the directory:
Use option at this time:-R
If Dest does not exist: creates the specified directory and copies all files in the SRC directory to dest;
If dest exists:
If Dest is a file: Error
If Dest is a directory:
Common options:
-I: Interactive
-R,-r: recursively copy directories and all internal content;
-A: Archive, equivalent to-DR--preserv=all
-d:--no-dereference--preserv=links
--preserv[=attr_list]
Mode: Permissions
Ownership: Belong to the main group
Timestamp
Links
Xattr
Context
All
-P:--preserv=mode,ownership,timestamp
-V:--verbose Show Execution effect
-F:--force forcibly
mv:move, moving files
MV [OPTION] ... SOURCE ... DIRECTORY
Common options:
-I: Interactive
-F: Mandatory
rm:remove, deleting
RM [OPTION] ... FILE ...
Common options:
-I: Interactive
-F: Force delete
-R: Recursive
command Aliases (alias)
Implemented by the alias command:
(1) Alias
Displays all the available command aliases for the current shell process;
(2) Alias Name= ' VALUE '
Defines the alias name, which is equivalent to executing the command value;
Note: Aliases defined on the command line are valid only for the current shell process, and are defined in the configuration file if you want to be permanently valid;
For the current user only: ~/.BASHRC
Valid for all users:/ETC/BASHRC
Note: The new configuration given by the edit configuration will not take effect immediately;
The bash process re-reads the configuration file:
Source/path/to/config_file
. /path/to/config_file
Undo Alias: Unalias
Unalias [-A] name [name ...]
Note: If the alias is the same as the name of the original command, you can use "\command" if you want to execute the original command;
Glob (globbing) wildcard character
Used in bash to implement file name "wildcard"
Wildcard characters: *,?, []
(1) *
Any character of any length
A*b:
AAB, AB, a123b,
Abc
(2)?
Any single character
A?b:
AaB
AB, A12B, ABC
(3) []
Matches any single character within the specified range
[0-9]
[A-Z]: character case insensitive
(4) [^]
Matches any single character outside the specified range
[^0-9]
Dedicated Character Set:
[:d Igit:]: Any number, equivalent to 0-9
[: Lower:]: Any lowercase letter
[: Upper:]: Any uppercase letter
[: Alpha:]: Any case letter
[: Alnum:]: Any number or letter
[: Space:]:
[:p UNCT:]: Punctuation
Bash's shortcut keys
Ctrl+l: Clear screen, equivalent to clear command;
CTRL + A: Jump to the beginning of the command;
Ctrl+e: Jumps to the end of the command;
CTRL + C: Cancel the execution of the command;
Ctrl+u: Deletes all content from the beginning of the command to the location of the village of Light;
Ctrl+k: Delete all the contents of the cursor at the end of the command line;
Linux Learning Diary-basic Commands (3)