I have the output (as below) which i want it to be in a table.
For e.g.
space utilization in PSE on path /logs is 0%
space utilization in PSE on path /logs/tuxedo/tuxlsp is 16%
space utilization in PSE on path /ldvarlsp/lsp/log is 37%
space utilization in PSE on path /home is 6%
space utilization in MOCK2 on path /logs is 2%
space utilization in MOCK2 on path /logs/tuxedo/tuxlsp is 85%
I want the output to be in table format say where 1st column is the server name (here PSE/MOCK2), 2nd column is path name, 3rd column is space utilization and so on.
in my code.. name of server, path name and space utlization value is stored in a variable.
kent$ cat t.txt
space utilization in PSE on path /logs is 0%
space utilization in PSE on path /logs/tuxedo/tuxlsp is 16%
space utilization in PSE on path /ldvarlsp/lsp/log is 37%
space utilization in PSE on path /home is 6%
space utilization in MOCK2 on path /logs is 2%
space utilization in MOCK2 on path /logs/tuxedo/tuxlsp is 85%
kent$ awk '{print "|"$4"#|"$7"#|"$9"# |"}' t.txt|column -s"#" -t |awk 'BEGIN{line=""}{l=length($0);if(length(line)==0)for(i=1;i<l;i++)line=line"-";print line;print $0}END{print line}'
-------------------------------------
|PSE |/logs |0% |
-------------------------------------
|PSE |/logs/tuxedo/tuxlsp |16% |
-------------------------------------
|PSE |/ldvarlsp/lsp/log |37% |
-------------------------------------
|PSE |/home |6% |
-------------------------------------
|MOCK2 |/logs |2% |
-------------------------------------
|MOCK2 |/logs/tuxedo/tuxlsp |85% |
-------------------------------------
You may not have column installed. It can handle the white spaces and give pretty output in your case. It saves a lot calculation too. You may want to install it or try others solutions.