我希望R打开在我的程序中创建的文件.我的代码使用以下代码将日志文件保存到名为logFile的变量中.
logFile <- sprintf("../output/%s_%s_output%sof%s.log", str1, str2, str3, str4);
Run Code Online (Sandbox Code Playgroud)
我试图通过调用来访问shell函数
shell('%s',logFile);
Run Code Online (Sandbox Code Playgroud)
但是我说错了
In shell("%s", toFile) : '%s' execution failed with error code 127
Run Code Online (Sandbox Code Playgroud)
如何在完成写入文件后让我的程序打开该文件?
我正在尝试从ls -lrth | grep TRACK输出中仅剪切日期部分:
-rw-r--r-- 1 ins ins 0 Dec 3 00:00 TRACK_1_20121203_01010014.LOG
-rw-r--r-- 1 ins ins 0 Dec 3 00:00 TRACK_0_20121203_01010014.LOG
-rw-r--r-- 1 ins ins 0 Dec 13 15:10 TRACK_9_20121213_01010014.LOG
-rw-r--r-- 1 ins ins 0 Dec 13 15:10 TRACK_8_20121213_01010014.LOG
Run Code Online (Sandbox Code Playgroud)
但是,这样做:
ls -lrth | grep TRACK | tr "\t" " " | cut -d" " -f 9
Run Code Online (Sandbox Code Playgroud)
只给我一个两位数的日期和单个数字的空格:
13
13
Run Code Online (Sandbox Code Playgroud)
所以我尝试使用tr命令,将所有单个数字日期翻译成两位数:
ls -lrth | grep TRACK | tr "\t" " " | tr "[1-9]" "['01'-'09']" …Run Code Online (Sandbox Code Playgroud) 我是shell脚本的新手,我想弄清楚以下内容.
如何在文件中搜索包含特定字符串的行,如果该行存在,则将该行复制到新文件中?
嗨我想在shell脚本中使用curl,如下所示,但我无法替换CURL中的变量$ line.请建议
while read line
do
echo "allowing mac $line"
curl -X POST -d '{"src-mac": "$line"}' http://localhost:8080/wm/firewall/rules/json
curl -X POST -d '{"dst-mac": "$line"}' http://localhost:8080/wm/firewall/rules/json
done < /home/floodlight/allowedmacs
Run Code Online (Sandbox Code Playgroud) 我有一个file.txt,文件的每一行都是这样的:
ABLED EY B AH L D
ABLER EY B AH L ER
Run Code Online (Sandbox Code Playgroud)
我希望每行的第二部分:EY B AH L D或者EY B AH L ER,例如,小写,保持其余的大写.我该怎么做?
非常感谢你提前.
我需要删除包含多个子目录和文件的目录.谷歌搜索和寻找的人的页面之后rmdir和rm我有两个选择:
$ rm -rf <folder_name> 和 $ \rm -rf <folder_name>
这两者有何不同?
如何返回$以外的值?来自ssh会话
例如:
x=5
echo "$x"
ssh -o StrictHostKeyChecking=no root@hostname "x=10"
echo "$x"
Run Code Online (Sandbox Code Playgroud)
这将打印
5
5
Run Code Online (Sandbox Code Playgroud)
但我需要新的价值
5
10
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用MongoDB shell删除文档,但由于某种原因,它一直在失败"无效对象id:length"
查询:
db.collections.remove( { _id : ObjectId("FF125DF6-E977-404A-9E8C-600CDAFEFF53" )} );
Run Code Online (Sandbox Code Playgroud)
错误:
周一12月24日3时十一分15秒断言:10448:无效对象ID:长度0x6073f1 0x5d1aa9 0x5ac3f1 0x5b84f4 0x6aa5ac 0x6aaec8 0x69e4e7 0x6aa13f 0x668e46 0x668ec2 0x66a2ce 0x5cbcc4 0x4a44a6 0x4a67e6 0x7f2554e2fcdd 0x49f669蒙戈(_ZN5mongo15printStackTraceERSo + 0×21)[0x6073f1]蒙戈(_ZN5mongo11msgassertedEiPKc + 0x99)[0x5d1aa9 ]蒙戈()[0x5ac3f1]蒙戈(_ZN5mongo21object_id_constructorEP9JSContextP8JSObjectjPlS4_ + 0x2b4)[0x5b84f4]蒙戈(js_Invoke +量0x40C)[0x6aa5ac]蒙戈(js_InvokeConstructor +量0x108)[0x6aaec8]蒙戈(js_Interpret + 0x37c7)[0x69e4e7]蒙戈(js_Execute + 0x36f) 0x6aa13f]蒙戈(JS_EvaluateUCScriptForPrincipals + 0x66)[0x668e46]蒙戈(JS_EvaluateUCScript +为0x22)[0x668ec2]蒙戈(JS_EvaluateScript + 0x6e)[0x66a2ce]蒙戈(_ZN5mongo7SMScope4execERKNS_10StringDataERKSsbbbi +量0x144)[0x5cbcc4]蒙戈(_Z5_mainiPPc + 0x2156)[0x4a44a6]蒙戈(主+ 0x26)[0x4a67e6] /lib64/libc.so.6(__libc_start_main+0xfd)[0x7f2554e2fcdd] mongo(__ gxx_personality_v0 + 0x2a1)[0x49f669] Mon Dec 24 03:11:15错误:无效对象i d:长度(壳):1
我试过跑步
db.repairDatabase();
Run Code Online (Sandbox Code Playgroud)
但没有任何改变.从检查周围我看到它的一个已知问题,有一个解决方法吗?
编辑
这是db中的文档:
{
"_id":"FF125DF6-E977-404A-9E8C-600CDAFEFF53",
"数据":{
Run Code Online (Sandbox Code Playgroud)"files": [ ], "categories": [ ], "trash": [ ] } …
我有一个文本文件(file.txt),其内容类似于:
foo1 3464
foo2 3696
foo3 4562
Run Code Online (Sandbox Code Playgroud)
它包含过程和相应的PID.
根据PID,我想使用shell脚本,在这个文件中追加一个字符串(运行/不运行).
例如,在上面的文件中,对于包含PID 3696的行,我想在末尾添加一个字符串"running",以便该文件变为:
foo1 3464
foo2 3696 running
foo3 4562
Run Code Online (Sandbox Code Playgroud)
我该怎么做?
我下载了最新的p4工具,但它缺少reconcile命令:
$ p4 -V
Perforce - The Fast Software Configuration Management System.
Copyright 1995-2012 Perforce Software. All rights reserved.
This product includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit (http://www.openssl.org/)
See 'p4 help legal' for full OpenSSL license information
Version of OpenSSL Libraries: OpenSSL 1.0.1c 10 May 2012
Rev. P4/LINUX26X86_64/2012.2/536738 (2012/10/16).
Run Code Online (Sandbox Code Playgroud)
这里是支持的命令列表(我删除了一些行):
$ p4 help commands
Perforce client commands:
add Open a new file to add it to the depot
admin Perform administrative …Run Code Online (Sandbox Code Playgroud)