如何从TAB分隔的字符串中选择第一列?
# echo "LOAD_SETTLED LOAD_INIT 2011-01-13 03:50:01" | awk -F'\t' '{print $1}'
Run Code Online (Sandbox Code Playgroud)
以上将返回整行,而不是按预期返回"LOAD_SETTLED".
更新:
我需要更改选项卡中的第三列分隔值.以下不起作用.
echo $line | awk 'BEGIN { -v var="$mycol_new" FS = "[ \t]+" } ; { print $1 $2 var $4 $5 $6 $7 $8 $9 }' >> /pdump/temp.txt
Run Code Online (Sandbox Code Playgroud)
但是,如果分隔符是逗号而不是制表符,则此操作会按预期工作.
echo $line | awk -v var="$mycol_new" -F'\t' '{print $1 "," $2 "," var "," $4 "," $5 "," $6 "," $7 "," $8 "," $9 "}' >> /pdump/temp.txt
Run Code Online (Sandbox Code Playgroud) 我正在寻找STDIN从外部进程向现有进程写入数据的方法,并发现了类似的问题 如何将数据从Python中的不同本地/远程进程流式传输到程序的STDIN中?在stackoverlow中.
在那个帖子中,@ Michael说我们可以在下面的路径中获取现有进程的文件描述符,并允许在Linux上将数据写入其中.
/proc/$PID/fd/
Run Code Online (Sandbox Code Playgroud)
所以,我创建了一个下面列出的简单脚本来测试从外部进程向脚本STDIN(和TTY)写入数据.
#!/usr/bin/env python
import os, sys
def get_ttyname():
for f in sys.stdin, sys.stdout, sys.stderr:
if f.isatty():
return os.ttyname(f.fileno())
return None
if __name__ == "__main__":
print("Try commands below")
print("$ echo 'foobar' > {0}".format(get_ttyname()))
print("$ echo 'foobar' > /proc/{0}/fd/0".format(os.getpid()))
print("read :: [" + sys.stdin.readline() + "]")
Run Code Online (Sandbox Code Playgroud)
这个测试脚本显示的路径STDIN和TTY,然后,等待一个写它STDIN.
我启动了这个脚本并在下面收到了消息.
Try commands below
$ echo 'foobar' > /dev/pts/6
$ echo 'foobar' > /proc/3308/fd/0
Run Code Online (Sandbox Code Playgroud)
所以,我执行的命令echo 'foobar' …
你好,我每个人都在使用qwt和我是新手我想用qwt和qt创建者绘制图形我不知道哪个librariesoz要包含在我的qt项目中以绘制图形我已经安装了qwt并且现在还包括插件和库请告诉我现在要用一个简单的例子做些什么
谢谢
我正在android环境中工作,并尝试了以下代码,但它似乎没有工作.
String [] stockArr = (String[]) stock_list.toArray();
Run Code Online (Sandbox Code Playgroud)
如果我定义如下:
String [] stockArr = {"hello", "world"};
Run Code Online (Sandbox Code Playgroud)
有用.有什么东西我不见了吗?
以下代码的输出是什么:
int main() {
int k = (k = 2) + (k = 3) + (k = 5);
printf("%d", k);
}
Run Code Online (Sandbox Code Playgroud)
它没有给出任何错误,为什么?我认为它应该给出错误,因为赋值操作与定义相同k.
我的意思是int i = i;无法编译.但它编译.为什么?什么是输出,为什么?
我想在android中以编程方式添加多个活动.我可以将这些活动添加到动态清单中,还是在android中有任何其他解决方案.
请分享您宝贵的建议.
如何防止意图定义继承定义的非继承方法.我被告知有诀窍表达它,但没有人能记得它.
说明.我有类的树:'Base'< - 'C'< - 'D',下面.Base定义了纯虚函数.该函数在C中重新定义,然后在D中重新定义.但该函数具有很长的参数列表.
在衍生链的某处,agrglist中存在微妙的错误,这使得D ::非继承.程序快速编译.并且在运行时调用错误的方法.
当方法是非继承时,是否存在导致编译错误的技巧.
#include <iostream>
class Base {
public:
virtual void VeryLongFunctionName(int VeryLongArgumentList) = 0;
};
class C : public Base {
public:
void VeryLongFunctionName(int VeryLongArgumentList) {
std::cout << "C::\n";
}
};
class D : public C {
public:
void VeryLongFunctionNane(int VeryLongArgumentList) { // typo is intentional. It's the point of the question.
std::cout << "D::\n";
}
};
int main() {
Base *p = new D;
p->VeryLongFunctionName(0);
// the intention is to print D::. …Run Code Online (Sandbox Code Playgroud) 默认的UIButton圆形矩形是深蓝色.我希望表格中的单元格文本与此蓝色相匹配.
我正在使用这个代码,但我能找到的唯一蓝色是亮蓝色......
cell.textLabel.textColor = [UIColor blueColor];
Run Code Online (Sandbox Code Playgroud)