问题
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
The script is working; the only problem is that when it is trying to rename the file I got the following error message:
mv: target `pollcodetemp_output*' is not a directory
Maybe it is something related with the IFS. I try to specify this at the beginning of the script as:
IFS='
'
But it is not working. I'm using a Windows text editor but I have already removed the CR.
回答1:
Most likely, you just need:
mv temp_output* "$code"
This will move the files named temp_output*
in the current directory to the directory specified in the variable $code
.
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
回答2:
You are trying to move multiple files to a name that is not a directory, which is not possible. This happens because you seem to be trying to rename from a wildcard pattern to a wildcard pattern, which is also not possible. I won't be guessing what exactly you're trying to accomplish, so I cannot give you any additional advice.
来源:https://stackoverflow.com/questions/11152444/bash-mv-not-a-directory