1

同様の文言を持つフォルダー内のファイルを別のフォルダーに削除しようとすると問題が発生します....そのようなファイルやディレクトリはないと言って吐き出します...

これは私がやっていることです:

mv "$OUTPUT_DIRECTORY/$RANDOM6* $OUTPUT_DIRECTORY/$YEAR/$MONTH/$DAY/"

前もって感謝します

4

2 に答える 2

3

You really want to have variable references (e.g. $OUTPUT_DIRECTORY) inside double-quotes to prevent the shell from overinterpreting their contents (e.g. treating spaces as word breaks rather than just part of the filename), but you cannot have the asterisk or the space between source and destination quoted, or they won't get interpreted. So here's what I'd recommend using:

mv "$OUTPUT_DIRECTORY/$RANDOM6"* "$OUTPUT_DIRECTORY/$YEAR/$MONTH/$DAY/"

Note that the first string is partly double-quoted (all of the parts with variables), and partly not quoted (the asterisk). This makes the shell apply the appropriate level and type of interpretation at each part of the string.

于 2013-03-28T14:40:13.053 に答える
0

プログラミングが不十分かどうかに関係なく、これは機能します。引用符を削除する必要がありました。

mv $OUTPUT_DIRECTORY/$RANDOM6* $OUTPUT_DIRECTORY/$YEAR/$MONTH/$DAY/

すべての変数は事前に発行されます....

于 2013-03-28T07:32:32.423 に答える