Answers for "awk column alignment"

0

awk column alignment

paste file1 file2 | awk '{printf "%0s   %0s    %-5s%9s    %7s    %0s %0s %0s %0s %0s %0s %0s %0s %0s %0s %0s %0s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13,$14,$15,$16,$17, $18}' > output
		^							 ^^^   ^^^^ ^(-5)mean ^(7)means alight to right, keep 7 string to left (eg : ----AAA)   	^ print your columns																
                                     ^^^			(-5)means, align to right keep 5 string to right(eg : AAA--)	
    								 this space keep 3 space between columns    
    % - to control number of digit. 0 mean everything,  
	s for string
    d for digit
    (-5s)means, align to left keep 5 string to right(eg : AAA--) , 
    (7s)means alight to right, keep 7 string to left (eg : ----AAA) 
   	string control and digit control is different, (digit chage the number, string keep the strings
    printf "%4.3e\n", 1950 will give 1.950e+03
    

ref : https://www.gnu.org/software/gawk/manual/html_node/Printf.html#Printf
Posted by: Guest on August-09-2021

Code answers related to "Shell/Bash"

Browse Popular Code Answers by Language