It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center。
7年前关闭。
我在使用此
当我打字
我的意思是,它没有错误,但没有任何作用。
当我使用VIM打开此文件时(我确实想上传图像,但是因为几天前注册了此站点而无法这样做)
到
全部染成红色。
在
颜色正常显示。
如果我在
所以我认为这一行:
是错的。我该如何纠正?
7年前关闭。
我在使用此
start.sh
脚本时遇到问题。当我打字
./start.sh
,它不起作用。我的意思是,它没有错误,但没有任何作用。
当我使用VIM打开此文件时(我确实想上传图像,但是因为几天前注册了此站点而无法这样做)
import sys,math,random
中的行到
print '\n'
是全部染成红色。
在
EOS
之后,颜色正常显示。
如果我在
#
前面键入cat
,我的意思是#cat <<EOS | python > target.txt
,颜色会改变。所以我认为这一行:
cat <<EOS | python > target.txt
是错的。我该如何纠正?
#!/bin/sh
if [ "$1" = clean ]; then
rm -f *.log *.dat target.txt
exit
fi
num=1
length=1000
period=50
cat <<EOS | python > target.txt
import sys,math,random
funcs = [
lambda t : (0.8 * math.sin(t), 0.8 * math.cos(t)),
lambda t : (0.3 * math.sin(t), 0.3 * math.cos(t)),
lambda t : (0.8 * math.sin(3 * t), 0.8 * math.cos(t)),
lambda t : (0.8 * math.cos(t), 0.8 * math.sin(3 * t)),
lambda t : (0.4 * math.sin(2 * t) + 0.4, 0.8 * math.cos(t)),
lambda t : (0.4 * math.sin(2 * t) - 0.4, 0.8 * math.cos(t)),
lambda t : (0.8 * math.sin(2 * t), 0.4 * math.cos(t) + 0.4),
lambda t : (0.8 * math.sin(2 * t), 0.4 * math.cos(t) - 0.4),
lambda t : (0.4 * math.cos(t) + 0.4, 0.8 * math.sin(2 * t)),
lambda t : (0.4 * math.cos(t) - 0.4, 0.8 * math.sin(2 * t)),
lambda t : (0.8 * math.cos(t), 0.4 * math.sin(2 * t) + 0.4),
lambda t : (0.8 * math.cos(t), 0.4 * math.sin(2 * t) - 0.4),
lambda t : (0.4 * math.sin(t) + 0.4, 0.8 * math.cos(t)),
lambda t : (0.4 * math.sin(t) - 0.4, 0.8 * math.cos(t)),
lambda t : (0.8 * math.sin(t), 0.4 * math.cos(t) - 0.4),
lambda t : (0.8 * math.sin(t), 0.4 * math.cos(t) + 0.4),
lambda t : (0.8 * math.sin(t), 0.8 * math.cos(2 * t)),
lambda t : (0.8 * math.sin(t), -0.8 * math.cos(2 * t)),
lambda t : (0.8 * math.cos(2 * t), 0.8 * math.sin(t)),
lambda t : (-0.8 * math.cos(2 * t), 0.8 * math.sin(t)),
lambda t : (0.3 * math.sin(t) + 0.5, 0.3 * math.cos(t) + 0.5),
lambda t : (0.3 * math.sin(t) + 0.5, 0.3 * math.cos(t) - 0.5),
lambda t : (0.3 * math.sin(t) - 0.5, 0.3 * math.cos(t) + 0.5),
lambda t : (0.3 * math.sin(t) - 0.5, 0.3 * math.cos(t) - 0.5)
]
def gen_sigma():
sigma = [0.01, 0.05]
n = 0
while True:
yield sigma[n % len(sigma)]
n += 1
gen = gen_sigma()
for f in funcs:
sigma = gen.next()
for n in xrange($num):
m = random.randint(0, 1000)
for t in [x * ((2 * math.pi) / $period) for x in xrange(m, $length+m)]:
print '\t'.join([str(x + random.gauss(0, sigma)) for x in f(t)])
print '\n'
EOS
if [ x`which rnn-learn` == x ]; then
path1=../../src/rnn-learn/
else
path1=
fi
${path1}rnn-learn -c config.txt target.txt
最佳答案
脚本没有任何明显的错误。用红色标记的部分是“此处文档”,从包含<<EOS
的行之后的行到仅包含EOS
的行。这里的文档是Python的标准输入,它将其输出写入文件target.txt
。脚本的其余部分在rnn-learn
文件上运行target.txt
命令,由配置文件config.txt
指导(我想)。
当您在包含#
命令的行之前放置cat
时,它将成为注释,因此以下几行是“只是shell脚本”,它们与shell脚本没有意义,但是vim
是很难知道(这是一个编辑!)。因此,它更改了线条的颜色,因为它们不再是here文档的一部分。cat
确实不是必需的。该行可能被写为:
python > target.txt <<EOS
关于linux - 好像是错误的shell脚本:cat ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14742613/