The mv command

'mv' is a command that we're going to use tomove files around or to rename them. 'mv' sort of has a split-personality 人格分裂 because it serves these two functions at the same time.


'mv' command for renaming files


Let's go back yet again to Tony's file, 'stuff' again. 'stuff' is not a good name for a file just as 'book' isn't a good name for a book. Just imagine: "The number one bestselling book this week is 'Book' by John Author.You should probably re-name this file to something meaningful. I would suggest doing something like this:


Code:
mv stuff tonys_jokes


You may have noticed the underscore '_' in the title.It's there because Linux doesn't really like spaces in the file names. You can do it and Linux will accept it but it will put a \\ between the different words.Spaces are sort of 'faux pas' in Linux but not 'verboten'.It would be to your advantage to use '_' between words though.



Moving files with the 'mv' command


Now you can use the 'mv' command to move Tony's jokes into the directory you made to keep his files.


Code:
mv tonys_jokes tonyd/

If you do cd tonyd and then ls to* you will see his file there along with 'toms_jokes' and 'tomato_soup_recipe'. (if you have another friend named Tom and you like to cook)


You can also move entire directories with this command. You do not have to use the '-r' option as you did with 'cp'. You would just substitute the file name for a directory name


Code:
mv tonyd/ my_friends/

would move the directory 'tonyd' to the directory 'my_friends'.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值