庆典:错误的行为在...循环与测试共同声明 [英] bash: wrong behavior in for... loop together with a test statement
问题描述
我想测试,如果某些文件,在TEXTFILES列表叫了起来,在某一目录中。每过一段时间(我敢肯定我每次都使用相同的语句)我得到一个错误,抱怨回声
命令无法找到。
I am trying to test if certain files, called up in a list of textfiles, are in a certain directory. Every once in a while (and I am quite certain I use the same statements every time) I get an error, complaining that the echo
command cannot be found.
我在我的目录 /音频/播放列表/
根据它们所应该使用的日期命名的TEXTFILES: 20130715 .TXT
例如今天:
The textfiles I have in my directory /audio/playlists/
are named according to their date on which they are supposed to be used: 20130715.txt
for example for today:
me@computer:/some/dir# ls /audio/playlists/
20130715.txt 20130802.txt 20130820.txt 20130907.txt 20130925.txt
20130716.txt 20130803.txt 20130821.txt 20130908.txt 20130926.txt
(...)
me@computer:/some/dir# cat /audio/playlists/20130715.txt
#A Comment line goes here
00:00:00 141-751.mp3
00:03:35 141-704.mp3
00:06:42 140-417.mp3
00:10:46 139-808.mp3
00:15:13 136-126.mp3
00:20:26 071-007.mp3
(...)
23:42:22 136-088.mp3
23:46:15 128-466.mp3
23:50:15 129-592.mp3
23:54:29 129-397.mp3
这么多的事实。下面的语句,这让我测试
如果所有的一切在给定的目录中TEXTFILES的呼吁文件实际上是在目录的文件/音频/ MP3 /
,产生一个错误:
So much for the facts. The following statement, which lets me test
if all files called upon in all of the textfiles in the given directory are actually a file in the directory /audio/mp3/
, produces an error:
me@computer:/some/dir# for i in $(cat /audio/playlists/*.txt|cut -c 10-16|sort|uniq); do [ -f "/audio/mp3s/$i.mp3" ] || echo $i; done
echo: command not found
me@computer:/some/dir#
我的猜的庆典
想抱怨述评系列(实际上行
)不是一个文件,但为什么会引起回声
不被发现?同样,大多的这个作品,但每隔一段时间我得到这个错误。任何帮助是极大的AP preciated。
I would guess bash
wants to complain about the "A Comment"-line (actually " line "
) not being a file, but why would that cause echo
not to be found? Again, mostly this works, but every so often I get this error. Any help is greatly appreciated.
推荐答案
在空间回声
不是U + 0020是U + 00A0。事实上,命令回声
不存在。
That space before echo
isn't U+0020, it's U+00A0. And indeed, the command " echo"
doesn't exist.
这篇关于庆典:错误的行为在...循环与测试共同声明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!