通过inode来mv文件
来源:互联网 发布:网络分销平台系统 编辑:程序博客网 时间:2024/04/28 12:03
通过inode来mv文件
Moving or rename files and directory using Linux mv command - Basic Linux Command.
Renaming Linux file and folder using Linux mv command, the mv command can be use to moving Linux files and directory to another location on the Linux system.
Command name: mv
The Linux command 'mv' can be use to rename files or to rename directory in Linux system. The 'mv' command also can be use to moving the files or to moving directory to different directory. The 'mv' command can be interpret as copying and then deleting the files or directory but this is done in much faster paste than manually copying and then deleting the files or folder.
Command Description:
Moving or renaming files or directory.
Command type:
In Fedora Core 5, mv command is aliased to 'mv -i', that means every mv command is execute in interactive mode.
[root@fedora ~]# type mv
mv is aliased to `mv -i'
Options that can be use with mv command:
• -i, --interactive, interactive mode and prompt before overwriting.
• -f, --force, force to overwrite even if the files or folder already exists.
• -u, --update, move when only the file is newer or not exists.
Rename Linux files using mv command.
The example below show how to use the mv command to rename a file install.log to install-fedora.log
[root@fedora ~]# pwd
/root
[root@fedora ~]# ls -l
total 100
-rw------- 1 root root 1209 Apr 9 21:38 anaconda-ks.cfg
drwx------ 2 root root 4096 Apr 8 19:06 Desktop
-rw-r--r-- 1 root root 28948 Apr 9 21:26 install.log
-rw-r--r-- 1 root root 4152 Apr 9 19:56 install.log.syslog
-rw-r--r-- 1 root root 28948 Apr 9 21:26 X.txt
[root@fedora ~]# mv install.log install-fedora.log
Verify using the ls command.
[root@fedora ~]# ls -l
total 100
-rw------- 1 root root 1209 Apr 9 21:38 anaconda-ks.cfg
drwx------ 2 root root 4096 Apr 8 19:06 Desktop
-rw-r--r-- 1 root root 28948 Apr 9 21:26 install-fedora.log
-rw-r--r-- 1 root root 4152 Apr 9 19:56 install.log.syslog
-rw-r--r-- 1 root root 28948 Apr 9 21:26 X.txt
[root@fedora ~]#
Command explanations:
• The 'pwd' command is to print the current directory that you are in:
pwd
• The use of 'ls -l' command is to list the contents inside the directory:
ls -l
• This is the part that where we use the 'mv' commad to rename file:
mv install.log install-fedora.log
• The 'ls -l' command is use again to verify the changes:
ls -l
Rename Linux files, base on file inode number.
To rename file or directory in Linux using the inode number, we need to know their inode number. Use the ' ls -i ' to find out the inode number for the files or directory.
[root@fedora ~]# ls -i
648389 anaconda-ks.cfg 97315 example-directory 1847716 install.log.syslog
97582 Desktop 1847715 install-fedora.log 648395 X.txt
Now let use the example-directory with inode number 97315 as an experiment for the example.
Now, execute the find command to find the example-directory inode number than rename that directory to new-directory-name.
[root@fedora ~]# find . -inum 97315 -exec mv {} new-directory-name /;
find: ./example-directory: No such file or directory
To verify the change on the directory name, use the ls command with the ' -i ' option to list file and folder including their inode number.
[root@fedora ~]# ls -i
648389 anaconda-ks.cfg 1847715 install-fedora.log 97315 new-directory-name
97582 Desktop 1847716 install.log.syslog 648395 X.txt
Command explanations:
• The 'ls -i' command is usually to get the inode number for file and directory in Linux or Unix system:
ls -i
• This line of command use 'find' command to find the inode number given than execute the 'mv' command to rename the file or directory:
find . -inum 97315 -exec mv {} new-directory-name /;
• To verify the changes to the filename 'ls -i' is use again:
ls -i
Moving files or directory to another location on the system.
The mv command is use to move or to rename a file or directory. This command is useful when you need to rename file or directory and to move file or directory to another location, for example:
[root@fedora ~]# mv install.log test/
The command above will move a file ( install.log ) from current directory and put the install.log file to the test directory.
[root@fedora ~]# mv -i install.log test/
mv: overwrite `test/install.log'? y
The command above will move a file ( install.log ) from current directory and put the install.log file to the test directory in interactive mode ( -i ), if the destination directory contain the file that used the same filename the command then prompt for user input to overwrite the file
[root@fedora5 ~]# mv install.log install-fedoracore.log
The command above will rename a file install.log to new file name install-fedoracore.log
[root@fedora5 ~]# mv * /etc/tmp/
The command above will move everything from current directory to destination directory that we specified in this example to /etc/tmp/ directory.
NAME:
mv - move (rename) files
Usage: mv [OPTION]... SOURCE DEST
or: mv [OPTION]... SOURCE... DIRECTORY
or: mv [OPTION]... --target-directory=DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.
for more information on using mv command:
# info mv
# man mv
# mv --help
Keywords: rename, move, moving, rename file, moving file, rename linux files, moving linux files, mv command, rename directory, rename folder, rename linux folder, mv linux files, moving linux directory, rename command.
- 通过inode来mv文件
- 通过文件的 inode 号来删除文件
- 通过 Inode 删除文件
- 根据inode编号来删除文件或目录
- 通过对inode的修改对文件操作进行扩充
- 优化 Ext4 分区格式化后占用空间(通过降低inode数来节省磁盘空间)
- 优化 Ext4 分区格式化后占用空间(通过降低inode数来节省磁盘空间)
- 通过servlet来下载文件
- 从inode角度描述cp,mv,rm行为
- mv排除某些文件
- inode 设备文件
- APUE 文件补充 inode
- Linux文件之inode
- 文件的inode数据
- 文件的inode数据
- linux文件与inode
- 通过JBuilder来制作exe文件来启动Java文件
- 通过XMLHTTP对象来实现文件下载
- 分页方案
- new:一种DLL插入方案
- 各种UNIX平台下vmstat与iostat输出结果详解_学习之用
- 求救!胜负比率计算问题?如何用SQL语句实现?(存储过程也可以)
- Google Inc 高级管理层
- 通过inode来mv文件
- 读写XML
- ASP.NET中的doPostBack脚本函数实例
- Oracle jdbc
- shellcode的一种ascii编码方法
- sql server jdbc
- 程序自动copy(Vc#&Oracle)
- An unhandled exception of type 'System.StackOverflowException'
- 巧用CSS解决asp.net中Gridview边框样式问题