我的脚本中有一部分根据filelist.txt获取文件数。我使用此命令将数字存储到变量中。
from collections import OrderedDict
df1.groupby(['date', 'tag']).agg(
dict(metric1='sum', metric2=['sum', 'mean'])
).pipe(
lambda d: pd.DataFrame(OrderedDict({'_'.join(k): v for k, v in d.iteritems()}))
).join(df2.set_index(['date', 'tag'])).reset_index()
date tag metric1_sum metric2_sum metric2_mean metric3
0 01-06-2017 A 2 1 0.500000 7
1 31-05-2017 A 0 0 0.000000 25
2 31-05-2017 B 1 2 0.666667 3
在我的CentOS VM Image中可以正常工作,但是当它在UNIX环境中执行时会显示以下错误:
filecount=$(wc -l ${script_path}/$filelist.txt | cut -d " " -f 1)
文件列表包含它,实际上只包含要处理的预期文件列表。
/myscript.sh: syntax error at line 50: `filecount=$' unexpected
./myscript.sh: [[: not found
对此有何看法?剪切不适用于unix吗?我可以使用哪些替代方法来获得所需的结果?
谢谢!
答案 0 :(得分:1)
我无法在UNIX sh
上进行测试,但我认为您只需将$()
替换为``
filecount=`wc -l ${script_path}/$filelist.txt | cut -d " " -f 1`
此致