Tags: Resolution type img Number requires test head file type otherI. File rename and move (MV)
In Linux, renaming files is called moving (moving). The MV command can move files and directories to another location or rename them.
1.1 Using the MV Rename
Below/usr/local create an empty file as test, using the MV command to rename to Test1, viewing the inode number and time will remain the same, because the MV only affects the file name. As shown in the following:
1.2 Moving position with MV
The following uses the MV to move the local test1 file to the/SRC directory, the inode number and time will remain unchanged, just move the location, as shown in:
When you move a file, you can also rename it, move the test1 to the/SRC directory below, and rename it to test2 file. As shown below:
The MV command can also move the directory (folder), and only the location is moved, and the inode number and time will remain unchanged. No more demonstrations here.
2.1 Using Rm-i
Rm-i parameter will prompt you whether to really delete the file, base shell does not have recycle Bin, delete cannot retrieve, add-I parameter develop good habit. Below the src directory to delete the test file, prompt whether to delete, enter n is not deleted, as shown in:
2.2 Using wildcard characters
Use the wildcard character "?" To delete, delete the test file below, beginning with the character T, the middle two wildcard characters "?", ending with the end character T.
3.1 Creating a single new directory
Create a directory in Linux use mkdir, below the USR directory to create a new directory file1, the new directory long list is the beginning of D, indicating that this is a directory. As shown below:
3.2 Creating a new catalog in bulk
If you need to create directories and subdirectories in bulk, you need to use the Mkdir-p parameter to do so, and then create the file1/log below in the USR directory, as shown below:
Delete Directory is rmdir, but only empty directory, if there are files in the directory will prevent the deletion. To solve this problem, the files in the directory must be deleted before the empty directory can be deleted using RmDir. You can use the Rm-ri command parameter to delete files under the directory and the directory itself. Delete file1/log/1.txt all directories and files below, use Rm-ri to complete
5.1 View File Types files
Before displaying the contents of a file, you should confirm the file type. Use the file command to view it as follows:
In addition to viewing the file type, you can also confirm that it is a symbolic connection, as shown in:
5.2 View Entire file cat
Below, use Cat-b to view the contents and line numbers as follows:
5.3 View File page flip more
For large files, use more to control the following operations, can be displayed per page, press SPACEBAR to page, press Q to exit.
There are more advanced less commands than more to view the files, which are no longer shown here.
5.4 Viewing the number of file trailing lines tail
Using the tail command, if you do not add any parameters, the first 10 lines of the file footer are displayed by default. Use the parameter-N to determine the number of rows displayed. Use the-f parameter to allow other processes to consume files while viewing the contents of the file. The following demo-N 5来 confirms that the trailing 5 lines of the file are displayed as shown in:
5.5 Viewing file header rows Head
The command is exactly the opposite of tail and has the-N and-f parameters. The following demo-N 5来 confirms that the first 5 lines of the file are displayed as shown in:
Linux Programming 5 (Directory rename with move mv, delete file rm, directory creation mkdir delete rmdir, view file,cat,more,tail,head)