移动名称中带有空格的文件 [英] moving a file with spaces in name

查看:55
本文介绍了移动名称中带有空格的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Unix中有一个文件名为这是我的文件.xls"

I have a file in unix with name as "this is my file.xls"

我想将其从一个文件夹移动到另一个文件夹.我写了以下几行:

I want to move it from one folder to other. I wrote the below lines:

fileName="this is my file"
myDate=20121125

mv $FIRST_DIR/"${fileName}.xls" $SECOND_DIR/"${fileName}_${myDate}.xls"

但是,这不起作用.我收到错误消息,因为"file.xls不是目录"

However, this is not working. I am getting error as "file.xls is not a directory"

正确的方法是什么?

感谢阅读!

推荐答案

对空格使用转义字符.因此,将变量 fileName 更改为"this \ is \ my \ file".这样可以确保外壳程序将忽略空格,并且不会将其视为定界符.

Use escape characters for spaces. So change the variable fileName to "this\ is\ my\ file". This ensures that the shell will ignore the spaces and won't consider it as a delimiter.

这篇关于移动名称中带有空格的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆