我正在使用LINUX,我希望使用shell来实现这一点。
我想从字段db2中提取字符串“”,这个字段对应于“”字段,这个字段是由/tab分隔的,而且我不能使用固定位置,因为它的大小是可变的。
的实际文件提取是:提供了2条记录,从时间戳开始。
Jeff Y:格式化数据
create_ts id tags title body answers
2011-01-03T20:52:52.880 5 **nosql^&^rdbms^&^database-recommendation** what are the differences between nosql and a traditional rdbms what are the differences between nosql and a traditional rdbms over the last few months nosql has been frequently mentioned in the technical news what are its most significant features relative to a traditional rdbms at what level physical logical do the differences occur where are the best places to use nosql why nosql is a kind of database that doesn t have a fixed schema like a traditional rdbms does with the nosql databases the schema is defined by the developer at run time they don t write normal sql statements against the database but instead use an
2011-01-04T14:26:06.730 162 sql^&^explain-plan^&^db2 what does hsjoin mean in an explain plan i have the following explain plan results from a query on my db2 database 0 select statement estimated costs 5 928e 02 timerons 1 return 2 hsjoin 3 o fetch ltbp 4 ixscan ltbp m key columns 0 5 i fetch ltbk 6 ixscan ltbk v key columns 0 what does the hsjoin on line 2 mean it s a hash join
2011-01-07T16:44:52.210 394 **database-recommendation^&^feature comparison^&^permissions** which database engines will allow me to grant revoke on a specific column if i have a table with a single column of sensitive data and i want to grant broad use of the table without exposing that one column i know that i can create a view that gives them access to all the non sensitive columns however postgresql allows you to grant column level permissions in the form of grant select col1 coln on table to role are there other engines which provide this capability sql server 2000 2005 2008 has this capability grant all privileges permission column n n on class securable to 发布于 2016-03-23 19:35:17
您的示例数据没有显示选项卡划界,但假设所有字段实际上都是选项卡分隔的:
使用awk,您需要拆分标签分隔符上的第三个字段,并在结果中查找您的标记:
awk -F"\t" '{split($3,a,/\^&\^/);for(t in a)if(a[t]=="db2"){print;next}}'发布于 2016-03-23 15:04:37
awk去营救!如果没有基于char计数的区域分隔标记,则可以限制模式匹配。
$ awk 'substr($0,start,length)~/pattern/' file例如,如果感兴趣的部分以14和9个字符的长度开始,则搜索模式abc。
$ awk 'substr($0,14,9)~/abc/' file如果数据是分隔的,例如使用选项卡,并且希望将搜索限制为字段2,则可以这样做。
$ awk -F'\t' '$2~/abc/' file当然,这些只是猜测,直到您有了一个具体的示例来演示真正的问题并验证脚本。
https://stackoverflow.com/questions/36181481
复制相似问题