巴什MV不是一个目录 [英] Bash mv not a directory
问题描述
我有我的脚本的一部分是这样的:
I have part of my script that goes like this:
while read line
do
code=`echo ${line} | awk '{print $1}'`
awk -f ${supscript}/rearrange.sh < ${base}/${code}
mv temp_output* "$code"temp_output*
done < filelist
脚本运行的唯一prolem是,当试图重命名文件,我得到了如下。
The script is working the only prolem is that when is trying to rename the file I got the follow.
mv: target `pollcodetemp_output*' is not a directory
也许是一些与IFS有关。我尝试在脚本的开头指定这样的:
Maybe is something related with the IFS. I try to specify this at the beginning of the script as:
IFS='
'
但不工作。我使用的是Windows的文本编辑器,但我已经删除了CR。
But is not working. I'm using a Windows text editor but I have already removed the CR.
推荐答案
最有可能的,你只需要:
Most likely, you just need:
mv temp_output* "$code"
这将移动名为 temp_output *
在当前目录中的变量指定的目录 $$ C $ç$ c中的文件$ C>。
This will move the files named temp_output*
in the current directory to the directory specified in the variable $code
.
但是,如果 $$ C $ç
是一个文件,那么你需要寻找一个改名
命令(有多种版本,不同的语法),或者你需要使用内循环:
However, if $code
is a file, then you need to look for a rename
command (there are several versions, with different syntaxes), or you need to use an inner loop:
for file in temp_output*
do mv "$file" "$code$file"
done
这篇关于巴什MV不是一个目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!