我试图逐行读取输入文件,其中包含由句点分隔的字段.我想将它们放入一个数组数组中,以便稍后我可以循环它们.输入似乎没问题,但是将它"推"到数组(inData)似乎不起作用.
代码如下:
Input file:
GSDB.GOSALESDW_DIST_INVENTORY_FACT.MONTH_KEY
GSDB.GOSALESDW_DIST_INVENTORY_FACT.ORGANIZATION_KEY
infile=${1}
OIFS=$IFS
IFS=":"
cat ${infile} | while read line
do
line=${line//\./:}
inarray=(${line})
# echo ${inarray[@]}
# echo ${#inarray[@]}
# echo ${inarray[0]}
# echo ${inarray[1]}
# echo ${inarray[2]}
inData=("${inData[@]}" "${inarray[@]}")
done
IFS=$OIFS
echo ${#inData[@]}
for ((i = 0; i < ${#inData[@]}; i++))
do
echo $i
for ((j = 0; j < ${#inData[$i][@]}; j++))
do
echo ${inData[$i][$j]}
done
done
Run Code Online (Sandbox Code Playgroud) 你能编写最简单的shell脚本,它会定期(例如1分钟)更改桌面壁纸(在Ubuntu中).
壁纸将保存在特定目录中(例如$ HOME/wallpapers).我只需要基本功能.
1)选择随机壁纸$HOME/wallpapers
2)将其设置为桌面上的壁纸
3)设置cron以每分钟运行脚本(不是问题的一部分).
from collections import *
ignore = ['the','a','if','in','it','of','or']
ArtofWarCounter = Counter(ArtofWarLIST)
for word in ArtofWarCounter:
if word in ignore:
del ArtofWarCounter[word]
Run Code Online (Sandbox Code Playgroud)
ArtofWarCounter是一个Counter对象,包含战争艺术中的所有单词.我正试图ignore从ArtofWarCounter 中删除单词.
追溯:
File "<pyshell#10>", line 1, in <module>
for word in ArtofWarCounter:
RuntimeError: dictionary changed size during iteration
Run Code Online (Sandbox Code Playgroud) 如何转换所有EOL(DOS的> UNIX)目录中的所有文件和子目录的递归没有 dos2unix?(我没有它,也无法安装它.)
有没有办法使用tr -d '\r'和管道?如果是这样,怎么样?
我有一个清单:
greeting = ['hello','my','name','is','bob','how','are','you']
Run Code Online (Sandbox Code Playgroud)
我想定义一个函数,它将在此列表中找到子列表的第一个和最后一个索引.从而:
find_sub_list(['my','name','is'], greeting)
Run Code Online (Sandbox Code Playgroud)
应该返回:
1, 3
Run Code Online (Sandbox Code Playgroud)
建议?
我想用Stanford NLP解析器解析句子列表.我的列表是一个ArrayList,如何解析所有列表LexicalizedParser?
我想从每个句子得到这种形式:
Tree parse = (Tree) lp1.apply(sentence);
Run Code Online (Sandbox Code Playgroud) 我知道以下开源工具,但我没有找到它们分别有多好的比较.准备使用短语提取的工具:
有没有人见过这样的比较?
我目前正在尝试创建一个安装包,使用autoconf生成配置文件.我已成功设法自动生成这些,但是,当我运行时./configure,没有生成makefile Makefile.in.
我的问题是:如何调试此问题以缩小失败的原因?
以下是我在尝试生成Makefile时收到的错误消息:
configure: error: cannot find install-sh, install.sh, or shtool
Run Code Online (Sandbox Code Playgroud) 我想知道我的网络硬件.
lspci | grep -i net
Run Code Online (Sandbox Code Playgroud)
从终端,此命令提供以下输出:
00:19.0以太网控制器:Intel公司82577LM千兆网络连接(rev 06)02:00.0网络控制器:Intel Corporation Centrino Advanced-N 6200(rev 35)
但是当我尝试从org-mode通过babel源块运行它时,我没有输出.
#+BEGIN_SRC sh
lspci | grep -i net
#+END_SRC
#+RESULTS:
Run Code Online (Sandbox Code Playgroud)
是什么赋予了?如何从终端获得相同的输出?
bash ×3
python ×3
shell ×2
unix ×2
arrays ×1
autoconf ×1
collections ×1
command-line ×1
configure ×1
containers ×1
counter ×1
emacs ×1
end-of-line ×1
gnome ×1
linux ×1
list ×1
nlp ×1
org-babel ×1
org-mode ×1
search ×1
stanford-nlp ×1
sublist ×1
time-series ×1
wallpaper ×1