Reconsider spacing of columns

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I have a file with the following format



1 1 1 0.02484183 57.2400000 24.6000000 
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000


I want instead to produce a file with the format below



 1 1 1 0.02484183 57.2400000 24.6000000 
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000









share|improve this question























  • So instead of defining space with awk like this 'print $1" "$2" "$3"..' to define characters (or real numbers) for each column)
    – Dimitris Mintis
    Aug 11 at 16:54














up vote
1
down vote

favorite












I have a file with the following format



1 1 1 0.02484183 57.2400000 24.6000000 
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000


I want instead to produce a file with the format below



 1 1 1 0.02484183 57.2400000 24.6000000 
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000









share|improve this question























  • So instead of defining space with awk like this 'print $1" "$2" "$3"..' to define characters (or real numbers) for each column)
    – Dimitris Mintis
    Aug 11 at 16:54












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have a file with the following format



1 1 1 0.02484183 57.2400000 24.6000000 
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000


I want instead to produce a file with the format below



 1 1 1 0.02484183 57.2400000 24.6000000 
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000









share|improve this question















I have a file with the following format



1 1 1 0.02484183 57.2400000 24.6000000 
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000


I want instead to produce a file with the format below



 1 1 1 0.02484183 57.2400000 24.6000000 
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000






awk text-formatting printf






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 11 at 18:23









Jeff Schaller

32.4k849110




32.4k849110










asked Aug 11 at 16:49









Dimitris Mintis

111




111











  • So instead of defining space with awk like this 'print $1" "$2" "$3"..' to define characters (or real numbers) for each column)
    – Dimitris Mintis
    Aug 11 at 16:54
















  • So instead of defining space with awk like this 'print $1" "$2" "$3"..' to define characters (or real numbers) for each column)
    – Dimitris Mintis
    Aug 11 at 16:54















So instead of defining space with awk like this 'print $1" "$2" "$3"..' to define characters (or real numbers) for each column)
– Dimitris Mintis
Aug 11 at 16:54




So instead of defining space with awk like this 'print $1" "$2" "$3"..' to define characters (or real numbers) for each column)
– Dimitris Mintis
Aug 11 at 16:54










2 Answers
2






active

oldest

votes

















up vote
3
down vote













awk using printf+%f



Try this. By using printf with a width modified (e.g. %2d, the field is padded as required). Similarly, % 2.8f formats a floating point number here.



$ awk 'printf "%2d%7d%7d % 2.8f % 2.7f % 2.7fn",$1,$2,$3,$4,$5,$6' file
1 1 1 0.02484183 57.2400000 24.6000000
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000
$


Try it online!



awk using printf+tabs



The tab (t) approach also suggested makes the code a lot cleaner, but it doesn't achieve the alignment quite as you request.



$ awk 'print $1"t"$2"t"$3"t"$4"t"$5"t"$6' file
1 1 1 0.02484183 57.2400000 24.6000000
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000


Codeless version, column



Again, not quite the output you request, but simple to achieve using column.



$ column -t file
1 1 1 0.02484183 57.2400000 24.6000000
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000
$





share|improve this answer


















  • 1




    awesome!!! I appreciate this a lot!!!
    – Dimitris Mintis
    Aug 11 at 17:42

















up vote
1
down vote













Read the file with awk and output the values with printf.



awk ' printf ("%2dt%st%st%11st%st%sn", $1, $2, $3, $4, $5, $6); ' file


Adapt the printf format string as you need.






share|improve this answer


















  • 1




    @steve The was just a t missing from t.
    – RalfFriedl
    Aug 11 at 20:10






  • 1




    @steve Of course, you are correct.
    – RalfFriedl
    Aug 11 at 22:07










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f462023%2freconsider-spacing-of-columns%23new-answer', 'question_page');

);

Post as a guest






























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
3
down vote













awk using printf+%f



Try this. By using printf with a width modified (e.g. %2d, the field is padded as required). Similarly, % 2.8f formats a floating point number here.



$ awk 'printf "%2d%7d%7d % 2.8f % 2.7f % 2.7fn",$1,$2,$3,$4,$5,$6' file
1 1 1 0.02484183 57.2400000 24.6000000
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000
$


Try it online!



awk using printf+tabs



The tab (t) approach also suggested makes the code a lot cleaner, but it doesn't achieve the alignment quite as you request.



$ awk 'print $1"t"$2"t"$3"t"$4"t"$5"t"$6' file
1 1 1 0.02484183 57.2400000 24.6000000
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000


Codeless version, column



Again, not quite the output you request, but simple to achieve using column.



$ column -t file
1 1 1 0.02484183 57.2400000 24.6000000
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000
$





share|improve this answer


















  • 1




    awesome!!! I appreciate this a lot!!!
    – Dimitris Mintis
    Aug 11 at 17:42














up vote
3
down vote













awk using printf+%f



Try this. By using printf with a width modified (e.g. %2d, the field is padded as required). Similarly, % 2.8f formats a floating point number here.



$ awk 'printf "%2d%7d%7d % 2.8f % 2.7f % 2.7fn",$1,$2,$3,$4,$5,$6' file
1 1 1 0.02484183 57.2400000 24.6000000
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000
$


Try it online!



awk using printf+tabs



The tab (t) approach also suggested makes the code a lot cleaner, but it doesn't achieve the alignment quite as you request.



$ awk 'print $1"t"$2"t"$3"t"$4"t"$5"t"$6' file
1 1 1 0.02484183 57.2400000 24.6000000
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000


Codeless version, column



Again, not quite the output you request, but simple to achieve using column.



$ column -t file
1 1 1 0.02484183 57.2400000 24.6000000
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000
$





share|improve this answer


















  • 1




    awesome!!! I appreciate this a lot!!!
    – Dimitris Mintis
    Aug 11 at 17:42












up vote
3
down vote










up vote
3
down vote









awk using printf+%f



Try this. By using printf with a width modified (e.g. %2d, the field is padded as required). Similarly, % 2.8f formats a floating point number here.



$ awk 'printf "%2d%7d%7d % 2.8f % 2.7f % 2.7fn",$1,$2,$3,$4,$5,$6' file
1 1 1 0.02484183 57.2400000 24.6000000
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000
$


Try it online!



awk using printf+tabs



The tab (t) approach also suggested makes the code a lot cleaner, but it doesn't achieve the alignment quite as you request.



$ awk 'print $1"t"$2"t"$3"t"$4"t"$5"t"$6' file
1 1 1 0.02484183 57.2400000 24.6000000
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000


Codeless version, column



Again, not quite the output you request, but simple to achieve using column.



$ column -t file
1 1 1 0.02484183 57.2400000 24.6000000
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000
$





share|improve this answer














awk using printf+%f



Try this. By using printf with a width modified (e.g. %2d, the field is padded as required). Similarly, % 2.8f formats a floating point number here.



$ awk 'printf "%2d%7d%7d % 2.8f % 2.7f % 2.7fn",$1,$2,$3,$4,$5,$6' file
1 1 1 0.02484183 57.2400000 24.6000000
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000
$


Try it online!



awk using printf+tabs



The tab (t) approach also suggested makes the code a lot cleaner, but it doesn't achieve the alignment quite as you request.



$ awk 'print $1"t"$2"t"$3"t"$4"t"$5"t"$6' file
1 1 1 0.02484183 57.2400000 24.6000000
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000


Codeless version, column



Again, not quite the output you request, but simple to achieve using column.



$ column -t file
1 1 1 0.02484183 57.2400000 24.6000000
2 1 2 -0.16091000 56.5200000 24.5600000
3 1 1 0.02484183 55.5700000 24.4900000
4 1 1 0.02484183 56.4400000 25.5100000
5 1 2 0.08638400 56.8900000 23.3300000
6 1 1 0.01376475 57.8900000 23.5200000
7 1 1 0.01376475 57.0600000 22.5200000
8 1 2 0.17612200 55.8800000 22.9700000
9 1 1 0.02042900 56.1600000 22.0400000
10 1 2 -0.34768900 55.9300000 24.0700000
11 1 1 0.07439383 55.5100000 25.0200000
12 1 1 0.07439383 55.4600000 23.7100000
13 1 1 0.07439383 57.0000000 24.2400000
14 1 2 0.02151800 54.4400000 22.8700000
15 1 1 0.08793975 54.5000000 22.4000000
$






share|improve this answer














share|improve this answer



share|improve this answer








edited Aug 11 at 17:34

























answered Aug 11 at 17:28









steve

12.9k22149




12.9k22149







  • 1




    awesome!!! I appreciate this a lot!!!
    – Dimitris Mintis
    Aug 11 at 17:42












  • 1




    awesome!!! I appreciate this a lot!!!
    – Dimitris Mintis
    Aug 11 at 17:42







1




1




awesome!!! I appreciate this a lot!!!
– Dimitris Mintis
Aug 11 at 17:42




awesome!!! I appreciate this a lot!!!
– Dimitris Mintis
Aug 11 at 17:42












up vote
1
down vote













Read the file with awk and output the values with printf.



awk ' printf ("%2dt%st%st%11st%st%sn", $1, $2, $3, $4, $5, $6); ' file


Adapt the printf format string as you need.






share|improve this answer


















  • 1




    @steve The was just a t missing from t.
    – RalfFriedl
    Aug 11 at 20:10






  • 1




    @steve Of course, you are correct.
    – RalfFriedl
    Aug 11 at 22:07














up vote
1
down vote













Read the file with awk and output the values with printf.



awk ' printf ("%2dt%st%st%11st%st%sn", $1, $2, $3, $4, $5, $6); ' file


Adapt the printf format string as you need.






share|improve this answer


















  • 1




    @steve The was just a t missing from t.
    – RalfFriedl
    Aug 11 at 20:10






  • 1




    @steve Of course, you are correct.
    – RalfFriedl
    Aug 11 at 22:07












up vote
1
down vote










up vote
1
down vote









Read the file with awk and output the values with printf.



awk ' printf ("%2dt%st%st%11st%st%sn", $1, $2, $3, $4, $5, $6); ' file


Adapt the printf format string as you need.






share|improve this answer














Read the file with awk and output the values with printf.



awk ' printf ("%2dt%st%st%11st%st%sn", $1, $2, $3, $4, $5, $6); ' file


Adapt the printf format string as you need.







share|improve this answer














share|improve this answer



share|improve this answer








edited Aug 11 at 22:07

























answered Aug 11 at 16:58









RalfFriedl

3,6401522




3,6401522







  • 1




    @steve The was just a t missing from t.
    – RalfFriedl
    Aug 11 at 20:10






  • 1




    @steve Of course, you are correct.
    – RalfFriedl
    Aug 11 at 22:07












  • 1




    @steve The was just a t missing from t.
    – RalfFriedl
    Aug 11 at 20:10






  • 1




    @steve Of course, you are correct.
    – RalfFriedl
    Aug 11 at 22:07







1




1




@steve The was just a t missing from t.
– RalfFriedl
Aug 11 at 20:10




@steve The was just a t missing from t.
– RalfFriedl
Aug 11 at 20:10




1




1




@steve Of course, you are correct.
– RalfFriedl
Aug 11 at 22:07




@steve Of course, you are correct.
– RalfFriedl
Aug 11 at 22:07

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f462023%2freconsider-spacing-of-columns%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?