Skip to content
Related Articles
Open in App
Not now

Related Articles

column command in Linux with examples

Improve Article
Save Article
Like Article
  • Difficulty Level : Easy
  • Last Updated : 28 Sep, 2021
Improve Article
Save Article
Like Article

column command in Linux is used to display the contents of a file in columns. The input may be taken from the standard input or from the file. This command basically breaks the input into multiple columns. Rows are filled before columns. Empty lines from the input are ignored unless the -e option is used. 

Syntax: 

column [-entx] [-c columns] [-s sep] [file ...]

Example:  

  • Suppose you have a text file with the following contents: 

sample file

  • To display the information of the text file in form of columns, you enter the command: 
column filename.txt

displays result

  • Suppose, you want to sort into different columns the entries that are separated by particular delimiters. For example, this sample text file: 

Sample text file

  • To separate the column based on the delimiter “|”, you would give the following command, which in turn produces the given output: 

output based on delimiter specified

  • In case you give multiple delimiters(same type), the command treats them as a single one. For example: 

sample text file

  • Upon application of command yields the output: 

Output(with multiple delimiters of same type)

Options:  

  • -J : This option specifies the system to display the output in JSON format.
  • -c : Defines the width of the output based upon the total number of characters allowed in one row.
  • -d : Used to define that the header is NOT to be printed.
  • -N : It defines the column names, and each name is separated by a comma(“, “).
  • -H : It is used to hide the specified columns from being displayed.
  • -V : Displays version information and exits.
  • -h : Shows help information and exits.
  • -s : Defines the column delimiter for output.
  • -t : Applied for creating a table by determining the number of columns.
  • -R : Used to right-align text in a specific column.
  • -T : Allows the system to truncate text wherever necessary so that the column width can be adjusted to ensure that the column doesn’t become too wide.
  • -O : Allows the user to define the order in which columns have to be displayed.
  • -L : Inserts empty lines after each row.

 

My Personal Notes arrow_drop_up
Like Article
Save Article
Related Articles

Start Your Coding Journey Now!