bash - Make grep output more readable -


I am working with grep in a file with a pattern grep -orI "id = \" [^ \] \ | \ "\." Sort | UniC-D which returns an output like the following:

  ./ myFile.html: id = "matchingR" ./myFile Html: id = "other" ./myFile .html: id = "cas" ./otherFile.html:id="what "./otherFile.html:id="Whairas" ./otherFile.html: Other "./otherFile.html:id="whatever" < / Code> 

What would be a convenient way for pipes, this is the output as follows:

  .mymyfile.html id = "matchingR" id = "Other "Id =" cas "./otherFile.html id =" what "id =" wheras "id =" other "id =" whatever " 

Group results.

Not the most beautiful but It works.

  awk -F: -v OFS =: 'F! = $ 1 {F = $ 1; Print F} F == $ 1 {$ 1 = "" ; $ 0 = $ 0; Sub (/ ^: /, ""); print} ' 

If any one of your lines is ever colonized, then this simple version Also works.

  awk -F: 'f! = $ 1 {f = $ 1; Print F} F == $ 1 {$ 1 = ""; Print' colon ( -F: ), these two split fields print the first field (filename), when it differs from a saved value (and saves) the new value) and when Matches the value saved, the first field when they first remove the field and print. They are different how they remove the fields and print out the output. The first attempt to preserve the colon in the match line is second (and the version of the @fedorakky  ... f == $ 1 {$ 0 = $ 2; print} ) assume that another colon line Were not to start. 


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -