Awk Record separations and loops -


Here I have the following data in a file to keep some minded information:

with Confusion Removed to avoid

The between separator (for example, using the date) and a column amount, to put data in I On the top row, I have a date: NAME -delim: with variable 2014, I can use

Trying to say: "????" Read this file, when you get a sample data ???? Just go through those lines, and type in column 7a

  awk -RS ???? Line Line -F: A ???? I have an estimate / sample data / '{sum = = $ 2} END {print sum}' filename.txt   

My guess is (to convert it to no byte), I Loop through them, MBS to store them, take them together, take GBS in the store, and add them too. Any sign? Wish Thinking:

  awk 'BEGIN {2014 = ""} {if ($ 8 == one [0-9] GB ") Size = amount + = $ 8 "GB"; and a ?? | Blah Blah Blah [0- 9] MB} a   

---- Edit

I have tried Here's the more accurate data that I'm working on (sorry, but I'm trying to reduce the data exposure here):

This is the right data set that works for the code Sampled revised

  July 2014: Data disks - 0: sample 0: 0: maps: on Quote: 0: Size 40GB15k: 20.00 GB: Segment: 3: Location ::: DA0000000000000000: 1: 1: Empty: 1: No: 0 1: Sample_1: 0: Maps: Online: 0: Size 40GB15 Key: 20.00 GB: Segment: 4: Location ::: DA 2000000000000031: 1: 1: Empty: 1: No: 0 2: Sample_2: 0: Maps: Online: 0: Size 40 GB 15K: 20.00 GB: Segment: 5: Location: : DA 2000000000000000032: 1: 1: Empty: 1: No: July 2014: Data Network - Border: 0: Sample_3: 0: Maps: Online: 0: Size 60 GB 15K: 10.00 GB: Segment: 3: Location: :: DA 200000000000000030: 1: 1: Empty: 1: No: 0 1: sample_4: 0: maps: online: 0: ax R 60 GB 15K: 10.00GB: Segment: 4: Location ::: DA 20000000000000 00031: 1: 1: Empty: 1: No: 0 2: Sample_4: 0: Maps: Online: 0: Size 60GB15k: 10.00 GB: Segment: 5: Location ::: DA 200000000000000032: 1: 1: Empty: 1: No: 0   

This worked against the set. Apart from this, the importance is also the following, if you notice, then after the date, the variables are different. I have: Disks, and data ... I do not need it / there is a summary of both examples. I would like to be able to say: "Look for the variable disk, and see all of you." Do not go into the data network

This solution uses a GNU awk extension, the contents of the capturing brackets To store

  gawk -F: '$ 1 ~ / ~ [[:: alpha:] [+: Points:]] + $ / {if amount (sum) printf "% S ", $ 0 sum = 0} / ^ [[blank:]] * $ / {next} {match ($ nf, / ([[digits:].] +) (| GB | TB) /, A ) If (a [2] == "GB") {sum + = a [1] * 1000} and if (a [2] == "TB") {sum + = a [1] * 1000 * 1000} And {sum + = a [1]}} end {print amount} '& lt; & Lt; END July 2014: Sample Data -Delim: 0: Sample 0: 0: Sample X: Online: 0: 2.00 TB 1: Sample 1: 0: Sample X: Online: 0: 2.00 TB 2: Sample 2: 0: Sample X : Online: 0: 2.00 TB July 2014: Other Data -Delim: 0: Sample 0: 0: 00: 1: Sample 1: 0: Sample X: Online: 0: 4.00 GB 2: Sample 2: 0: Sample X: Online: 0: 5.00 GB July 2014: Even more data -Delimal: 0: Sample 0: 0: Sample X: Online: 0: 9.00 GB 1: Sample 1: 0: Sample X: Online: 0: 10.00 TB 2: Sample 2: 0: Sample X: Online: July 2014: Sample data -Delim: 6000000 July 2014: Other data -Delim: 9003 July 2014: More data-yet: 1000 9 011 < / Code>   
  gawk -F: '$ 1 ~ / ^ [[: alpha:]] + [[: points:]] + $ / {If (($ 8, / $) / $ [{: blank:]] * $ / {next} do_sum {match ($ 8 / /) ([[digits:].) +) (| GB | TB) /, A) If (a [2] == "GB") {sum + = a [1] * 1000} and if (a [2] == "TB") {sum + = a [1] ] * 1000 * 1000} and {sum + = a [1]}} end {if (do_sum) print amount} '  

for the same data, it prints

  July 2014: Data Disk-Dilem: 60000    

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -