【发布时间】:2015-02-27 10:03:22
【问题描述】:
我在脚本文件中使用“mkdir”时遇到问题。
这是我的脚本
#!/bin/bash
mkdir "wavlist"
cat 0160.121213.084834.log 0161.121213.085943.log 0162.121214.004916.log | grep .\.wav | cut -f 1 -d ' ' > wavlist/drills01.wavlist
每当我执行此操作时。它将创建的目录名为“wavlist”。
为什么会有“。”最后?
bash -x 的输出
+ $'\r'
Drills01Commands_Celso.sh: line 2: $'\r': command not found
+ mkdir $'wavlist\r'
+ $'\r'
Drills01Commands_Celso.sh: line 4: $'\r': command not found
+ cat logfiles/0160.121213.084834.log logfiles/0161.121213.085943.log logfiles/0162.121214.004916.log
+ grep ..wav
+ cut -f 1 -d ' '
: No such file or directoryline 5: wavlist/drills01.wavlist
+ $'\r'
Drills01Commands_Celso.sh: line 6: $'\r': command not found
【问题讨论】:
-
不应该。其他事情正在发生。脚本中还有其他
mkdirs 吗? -
无。剧本就是这么短。我正在使用 cygwin。
-
bash -x script的输出是什么?type -a mkdir的输出是什么? -
听起来像一个错误。我无法使用 Cygwin 的 coreutils v. 8.23 重现该行为。也许更新会有所帮助。
-
这是 bash -x 脚本的输出。 @michas $ bash -x Drills01Commands_Celso.sh + $'\r' Drills01Commands_Celso.sh:第 2 行:$'\r':找不到命令 + mkdir $'wavlist\r' + $'\r' Drills01Commands_Celso.sh:行4: $'\r': 找不到命令 + cat logfiles/0160.121213.084834.log logfiles/0161.121213.085943.log logfiles/0162.121214.004916.log + grep ..wav + cut -f 1 -d ' ' : 否这样的文件或目录第 5 行:wavlist/drills01.wavlist + $'\r' Drills01Commands_Celso.sh:第 6 行:$'\r':找不到命令