awk

How to parse contents of a file using sed/awk?

我是研究僧i 提交于 2020-01-03 17:34:30
问题 My input file has its content in following format, where each column is separated by a "space" string1<space>string2<space>string3<space>YYYY-mm-dd<space>hh:mm:ss.SSS<space>string4<space>10:1234567890<space>0e:Apple 1.2.3.4<space><space>string5<space>HEX There are 2 "spaces" after "0e:Apple 1.2.3.4" because there is no 14th digit in this field/column. The entire "0e:Apple 1.2.3.4space" is treated as a single value of that column. In the 7th column, 10: represents the count of characters in

Remove all character after matched character

梦想与她 提交于 2020-01-03 17:30:54
问题 I have a file with many lines http://example.com/part-1 this number 1 one http://example.com/part--2 this is number 21 two http://example.com/part10 this is an number 12 ten http://example.com/part-num-11 this is an axample number 212 eleven How can I remove all character after "number x" + between first columd and "number x"...I wanna my output like this http://example.com/part-1 1 http://example.com/part--2 21 http://example.com/part10 12 http://example.com/part-num-11 212 Another case :

How to replace text using sed or awk?

一曲冷凌霜 提交于 2020-01-03 17:08:04
问题 I have the following json file: { "last_modified": { "type": "/type/datetime", "value": "2008-04-01T03:28:50.625462" }, "type": { "key": "/type/author" }, "name": "National Research Council. Committee on the Scientific and Technologic Base of Puerto Rico"s Economy.", "key": "/authors/OL2108538A", "revision": 1 } The name value has a double quote and I only want to replace this double quote with a single quote (not any other double quote). How can I do it? 回答1: If you want to repleace all

How to replace text using sed or awk?

一笑奈何 提交于 2020-01-03 17:07:23
问题 I have the following json file: { "last_modified": { "type": "/type/datetime", "value": "2008-04-01T03:28:50.625462" }, "type": { "key": "/type/author" }, "name": "National Research Council. Committee on the Scientific and Technologic Base of Puerto Rico"s Economy.", "key": "/authors/OL2108538A", "revision": 1 } The name value has a double quote and I only want to replace this double quote with a single quote (not any other double quote). How can I do it? 回答1: If you want to repleace all

Join multiple tables by row names [duplicate]

断了今生、忘了曾经 提交于 2020-01-03 16:36:34
问题 This question already has answers here : Merging very large csv files with common column (6 answers) Closed 5 years ago . I would like to merge multiple tables by row names. The tables differ in the amount of rows and they have unique and shared rows, which should all appear in output. If possible I would like to solve the problem with awk , but I am also fine with other solutions. table1.tab a 5 b 5 d 9 table2.tab a 1 b 2 c 8 e 11 The output I would like to obtain the following table: table3

Find unique string within a file, up a line and append?

本小妞迷上赌 提交于 2020-01-03 15:58:04
问题 Can someone please help me with this scenario? I'm looking for a SED or AWK command that I can use to find a unique string within a config file (Linux), go up a line and append a string to the end of that line? For example: config file: define hostgroup{ hostgroup_name http-urls ; The name of the hostgroup alias HTTP URLs ; Long name of the group members domain1.com, domain2.com, domain3.com, #MyUniqueString } In the above example, I'd like to use SED or AWK to find #MyUniqeString , go up a

Find unique string within a file, up a line and append?

こ雲淡風輕ζ 提交于 2020-01-03 15:57:30
问题 Can someone please help me with this scenario? I'm looking for a SED or AWK command that I can use to find a unique string within a config file (Linux), go up a line and append a string to the end of that line? For example: config file: define hostgroup{ hostgroup_name http-urls ; The name of the hostgroup alias HTTP URLs ; Long name of the group members domain1.com, domain2.com, domain3.com, #MyUniqueString } In the above example, I'd like to use SED or AWK to find #MyUniqeString , go up a

How to remove space/TAB from command output

前提是你 提交于 2020-01-03 06:33:23
问题 Please advice about the following understanding problem ??? I type on my linux machine this: ( in order to get the total memory by top command ) top -n1 | grep Mem: Mem: 2075024k total, 2059064k used, 15960k free, 249212k buffers so now I want to get the total memory that exists in the second field so I do this: # top -n1 | grep Mem: | awk '{print $2}' but no any results !!! -:( but if I do this: ( the third field ) , then I get the total value in spite the value exists in the second field ??

I need to merge two files and create a new files

寵の児 提交于 2020-01-03 06:32:09
问题 input 1 1 10611 2 122 C :0.983607 G :0.0163934 input 2 1 10611 rs146752890 C G 100 PASS AC=184;RSQ=0.8228;AVGPOST=0.9640;AN=2184;ERATE=0.0031;VT=SNP;AA=.;THETA=0.0127;LDAF=0.0902;SNPSOURCE=LOWCOV;AF=0.08;ASN_AF=0.08;AMR_AF=0.14;AFR_AF=0.08;EUR_AF=0.07 here 1st and 2nd column are matching and values before ':' of 5th column of first file and 4th column of 2nd files are equel and 6th column(values before ':') of first and 5th column of second files are equel and output is creating based on this

While read line, awk $line and write to variable

╄→尐↘猪︶ㄣ 提交于 2020-01-03 05:37:29
问题 I am trying to split a file into different smaller files depending on the value of the fifth field. A very nice way to do this was already suggested and also here. However, I am trying to incorporate this into a .sh script for qsub, without much success. The problem is that in the section where the file to which output the line is specified, i.e., f = "Alignments_" $5 ".sam" print > f , I need to pass a variable declared earlier in the script, which specifies the directory where the file