awk

Print lines containing the same second field for more than 3 times in a text file

梦想的初衷 提交于 2021-02-11 12:33:08
问题 Here is what I am doing. The text file is comma separated and has three field, and I want to extract all the line containing the same second field more than three times. Text file (filename is "text"): 11,keyword1,content1 4,keyword1,content3 5,keyword1,content2 6,keyword2,content5 6,keyword2,content5 7,keyword1,content4 8,keyword1,content2 1,keyword1,content2 My command is like below. cat the whole text file inside awk and grep with the second field of each line and count the number of the

How to divide specific column with rest of columns

泄露秘密 提交于 2021-02-11 12:18:24
问题 I have matrix like this (first column names rest are values, separator i tab): name1 A1 B1 C1 D1 name2 A2 B2 C2 D2 Matrix could be huge (it is mean about hundreds rows and columns). It is allays same size. I can expect zero values. I need output like this: name1 A1 B1 C1 D1 A1/B1 A1/C1 A1/D1 name2 A2 B2 C2 D2 A2/B2 A2/C2 A2/D2 This combination save to new file. And then make another combination: name1 A1 B1 C1 D1 B1/A1 B1/C1 B1/D1 name2 A2 B2 C2 D2 B2/A2 B2/C2 B2/D2 and so on so on => divide

How to divide specific column with rest of columns

拈花ヽ惹草 提交于 2021-02-11 12:17:29
问题 I have matrix like this (first column names rest are values, separator i tab): name1 A1 B1 C1 D1 name2 A2 B2 C2 D2 Matrix could be huge (it is mean about hundreds rows and columns). It is allays same size. I can expect zero values. I need output like this: name1 A1 B1 C1 D1 A1/B1 A1/C1 A1/D1 name2 A2 B2 C2 D2 A2/B2 A2/C2 A2/D2 This combination save to new file. And then make another combination: name1 A1 B1 C1 D1 B1/A1 B1/C1 B1/D1 name2 A2 B2 C2 D2 B2/A2 B2/C2 B2/D2 and so on so on => divide

awk printf a particular column in a file

核能气质少年 提交于 2021-02-11 12:12:05
问题 I want to print a particular column (in this case column 7) of my file in scientific notation, whereas rest of the columns get printed as is. How can I selectively use printf only for column 7 and just print for first 6 columns? example input: C 6 12.011 0.51 3.56E-01 4.60E-01 0.458399 CA 6 12.011 -0.15 3.55E-01 2.93E-01 0.291708 CAI 6 12.011 -0.25 3.55E-01 3.05E-01 0.30421 CC 6 12.011 0.62 3.56E-01 2.93E-01 0.291708 desired output: C 6 12.011 0.51 3.56E-01 4.60E-01 4.58E-01 CA 6 12.011 -0.15

How to read a file and get certain lines in Linux

帅比萌擦擦* 提交于 2021-02-11 07:16:19
问题 I have a file and it has content like this: abc.com. IN A 10.10.40.94 ;10.120.40.61 ;10.60.3.135 def.com. IN CNAME some-domain.com. xyz.com. IN A 10.123.40.32 ;10.145.40.133 ;1.240.3.215 one.com. IN CNAME some-other-domain.com. What I want to do is, get all the lines with IN A and print them to another file so the final file would look like below: I tried awk as follows: cat dev-mytaxi.com.zone | awk '{print $3}' but how can I write to a file and the final outcome as mentioned below? final

How to read a file and get certain lines in Linux

送分小仙女□ 提交于 2021-02-11 07:15:56
问题 I have a file and it has content like this: abc.com. IN A 10.10.40.94 ;10.120.40.61 ;10.60.3.135 def.com. IN CNAME some-domain.com. xyz.com. IN A 10.123.40.32 ;10.145.40.133 ;1.240.3.215 one.com. IN CNAME some-other-domain.com. What I want to do is, get all the lines with IN A and print them to another file so the final file would look like below: I tried awk as follows: cat dev-mytaxi.com.zone | awk '{print $3}' but how can I write to a file and the final outcome as mentioned below? final

How to read a file and get certain lines in Linux

妖精的绣舞 提交于 2021-02-11 07:15:04
问题 I have a file and it has content like this: abc.com. IN A 10.10.40.94 ;10.120.40.61 ;10.60.3.135 def.com. IN CNAME some-domain.com. xyz.com. IN A 10.123.40.32 ;10.145.40.133 ;1.240.3.215 one.com. IN CNAME some-other-domain.com. What I want to do is, get all the lines with IN A and print them to another file so the final file would look like below: I tried awk as follows: cat dev-mytaxi.com.zone | awk '{print $3}' but how can I write to a file and the final outcome as mentioned below? final

How to read a file and get certain lines in Linux

佐手、 提交于 2021-02-11 07:14:12
问题 I have a file and it has content like this: abc.com. IN A 10.10.40.94 ;10.120.40.61 ;10.60.3.135 def.com. IN CNAME some-domain.com. xyz.com. IN A 10.123.40.32 ;10.145.40.133 ;1.240.3.215 one.com. IN CNAME some-other-domain.com. What I want to do is, get all the lines with IN A and print them to another file so the final file would look like below: I tried awk as follows: cat dev-mytaxi.com.zone | awk '{print $3}' but how can I write to a file and the final outcome as mentioned below? final

Strange behavior when parsing result from curl + awk

纵然是瞬间 提交于 2021-02-11 06:08:42
问题 Using curl on ubuntu I am trying to fetch the Jenkins version inspired by: https://wiki.jenkins.io/display/JENKINS/Remote+access+API In a bash script I do: VERSION=$(curl -k -i -X GET --insecure --silent --header \"Authorization: Bearer $TOKEN \" $URL | grep -Fi X-Jenkins: | awk '{print $2}') echo "__A__[${VERSION}]__B__" But when I run the script I get: ]__B__2.89.2 So for some reason the prefix: __A__[ gets swallowed and the suffix gets turned into a prefix . I have also tried to trim the

Strange behavior when parsing result from curl + awk

流过昼夜 提交于 2021-02-11 05:59:06
问题 Using curl on ubuntu I am trying to fetch the Jenkins version inspired by: https://wiki.jenkins.io/display/JENKINS/Remote+access+API In a bash script I do: VERSION=$(curl -k -i -X GET --insecure --silent --header \"Authorization: Bearer $TOKEN \" $URL | grep -Fi X-Jenkins: | awk '{print $2}') echo "__A__[${VERSION}]__B__" But when I run the script I get: ]__B__2.89.2 So for some reason the prefix: __A__[ gets swallowed and the suffix gets turned into a prefix . I have also tried to trim the