Forrest logo
back to the printf tool

column:tldr:6e25e

column: Split columns automatically and auto-align them in a tabular format.
$ printf "header1 header2\nbar foo\n" | column --table
try on your machine

This command uses the printf and column commands to format some text into a table.

Here's a breakdown of the command:

  1. printf "header1 header2\nbar foo\n": This uses the printf command to format a string with two lines of values. The first line contains headers "header1" and "header2", separated by a space. The second line contains values "bar" and "foo", also separated by a space. The \n represents newlines.

  2. |: The vertical bar (pipe) symbol is used to connect the output of the printf command to the input of the column command. This is called a pipe and allows us to pass the output of one command as the input to another command.

  3. column --table: This uses the column command with the --table option to format the input data into a table. The --table option arranges the input as a table, with appropriate spacing and alignment.

So, when the command is executed, the printf command generates the text with headers and values, and then pipes it to the column command, which formats it into a neat table. The output will display a two-column table with headers "header1" and "header2" and corresponding values "bar" and "foo".

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the printf tool