Addition, deletion, modification, and checking of files

1.1.cp

Parameter description:
1.-a: Keep the link and file attributes, and copy all the contents under the directory. Its effect is equal to the combination of dpR parameters.
2.-d: Keep the link when copying. The link mentioned here is equivalent to a shortcut in the Windows system.
3.-f: Overwrite the existing target file without prompting.
4.-i: Give a prompt before overwriting the target file, asking the user to confirm whether to overwrite, the target file will be overwritten when answering "y".
5.-p: In addition to copying the content of the file, the modification time and access permissions are also copied to the new file.
6.-r: If the given source file is a directory file, all the subdirectories and files in the directory will be copied at this time.
7.-l: Do not copy files, just generate link files.

Copy aa to the /root directory

[root@rhcsa ~]# cp -a  aa /root

1.2.rm

Parameters:
1.-i Ask for confirmation one by one before deleting.
2.-f Even if the original file attribute is set as read-only, it will be deleted directly without confirming one by one.
3.-r Delete the files in the directory and below one by one.
Empty xx/ directory

[root@rhcsa ~]# rm -rf xx/* 

1.3.mv

Parameter description:
-i: if there is a file with the same name in the specified directory, first ask whether to overwrite the old file;
-f: do not give any instructions when the mv operation wants to overwrite an existing target file;
-b: when the file exists, Before overwriting, create a backup for it;
-S<suffix>: specify a suffix for the backup file, instead of using the default suffix;
-u: execute the move operation when the source file is newer than the target file or the target file does not exist.

Move test01 to the /opt/xx directory (test01 already exists in this directory)

[root@rhcsa opt]# mv -b test01 /opt/xx/
mv: overwrite ‘/opt/xx/test01’? y
[root@rhcsa opt]# cd xx
[root@rhcsa xx]# ll
total 0
-rw-r--r--. 1 root root 0 Oct  7 00:27 test01
-rw-r--r--. 1 root root 0 Oct  7 00:26 test01~  (系统自动创建的备份)
[root@rhcsa xx]# 

1.4.touch

Introduction: Usually used to update the file timestamp or create a new file
parameter and option
a to change the read time record of the file.
m Change the modification time record of the file.
c If the destination file does not exist, no new file will be created. Same effect as --no-create.
f is not used, it is reserved for compatibility with other unix systems.
r Use the time record of the reference file, which has the same effect as --file.
d Set the time and date, you can use a variety of different formats.
t Set the time record of the file, the format is the same as the date command.
--no-create will not create a new file.
--help List the command format.
--version List version information.

1.5.mkdir

Introduction: Create a directory
parameter and option
-p to ensure that the directory name exists, and create one if it does not exist.

1.6. Redirection:>, >>

echo "content">>filename

Guess you like

Origin blog.51cto.com/14539398/2676147