操作文件和目录【TLCL】
-
cp – Copy files and directories
-
mv – Move/rename files and directories
-
mkdir – Create directories
-
rm – Remove files and directories
-
ln – Create hard and symbolic links
通配符
Wildcard | Meaning |
---|---|
* | Matches any characters |
? | Matches any single character |
[characters] | Matches any character that is a member of the set characters |
[!characters] | Matches any character that is not a member of the set characters |
[[:class:]] | Matches any character that is a member of the specified class |
字符类
Character Class | Meaning |
---|---|
[:alnum:] | Matches any alphanumeric character |
[:alpha:] | Matches any alphabetic character |
[:digit:] | Matches any numeral |
[:lower:] | Matches any lowercase letter |
[:upper:] | Matches any uppercase letter |
-
mkdir directory...
-
cp item1 item2
-
cp item... directory
Option | Meaning |
---|---|
-a, --archive | Copy the files and directories and all of their attributes, including ownerships and permissions. Normally, copies take on the default attributes of the user performing the copy |
-i, --interactive | Before overwriting an existing file, prompt the user for confirmation. If this option is not specified, cp will silently overwrite files. |
-r, --recursive | Recursively copy directories and their contents. This option (or the -a option) is required when copying directories. |
-u, --update | When copying files from one directory to another, only copy files that either don't exist, or are newer than the existing corresponding files, in the destination directory. |
-v, --verbose | Display informative messages as the copy is performed. |
mv item1 item2
mv item... directory
rm item...
先用 ls 命令来测试通配符
ln file link 硬链接
-
ln -s item link 符号链接
硬链接不能关联文件系统之外的文件,不能关联目录