mardi 24 février 2015

Produce aligned columns in a shell script


In shell how do I have an even length of spaces by the length of words on my menu?


I've tried to get the length of the longest character string and then create each column length by the longest string+1... also I'm having problems with this a lot and I'd like to read more on this topic.


Would it be awk or grep?



menuNAME menuNAME2 menuNAME3
word word2 THISwordisLongest
THISwordisLongest word wordLONG
wordLONG THISwordisLongest word


Expected output:



menuNAME menuNAME2 menuNAME3
word wordLONG THISwordisLongest
THISwordisLongest word wordLONG
wordLONG THISwordisLongest word


Aucun commentaire:

Enregistrer un commentaire