Home > OS >  Consult a regular problem
Consult a regular problem

Time:09-30



I want to move that last one up front, there is no perfect solution, test the sed and awk seems to be not perfect solution! Pray god to help and have a look

CodePudding user response:

 
Output | awk '{printf "% 100-15 - s % s \ n", $NF, $0}' | sed -r 's [[: blank:]] + $///' | sed -r 's/(^. *) ([[: blank:]] +) 1/(. * $)/\'

A little complicated, look line not line (premise is the last column is not null, free value there will be a problem)
1) the awk '{printf "% 100-15 - s % s \ n", $NF, $0}' to the last field in a row in the first column of output again (the last column free value, that wouldn't work; Was prepared to use awk '{$NF=""; Print} 'to replace the last field is empty to remove the last column, but found that format is wrong, bad alignment, with the two sed processing)
2) sed - r 's [[: blank:]] + $///' removes white Spaces at the end of each line of the
3) sed - r 's/(^. *) ([[: blank:]] +) (. * $)/1/\' group, removes white Spaces at the front of the last column and last column

CodePudding user response:

The other 15-100 - s and % s is % I casually, you according to your output, have a look at how much the actual character width, you of the two values should be bigger

CodePudding user response:

Well, thank you very much, just tried it on, your method is ok!
But could you tell me the [[: blank:]] + and + [\ s] what is the difference between the two? After I changed [\ s] + is not the same, great changes
  • Related