Javatpoint Logo
Javatpoint Logo

Linux cut

The 'cut' command is useful in selecting a specific column of a file. After (-d), delimiter (from where you want to separate the columns) comes. Delimiters can be a space (' '), a hyphen (-), a slash (/) or anything else. After (-f), column number is mentioned.

Syntax:

Hyphen (-) As Delimiter

Syntax:

Example:

Linux Cut Filter1

Look at the above snapshot, our delimiter is hyphen (-), hence we have used (-) after (-d). Command "cut -d- -f1 marks.txt" displays column 1 and command "cut -d- -f2 marks.txt" displays column 2.

Space As Delimiter

If you want to use space as a delimiter then you have to quote the space (' ').

Syntax:

Example:

Linux Cut Filter2

Look at the above snapshot, our delimiter is space, hence we have used (' ') after (-d). Command "cut -d ' ' -f2 marks.txt" displays column 2, command "cut -d ' '-f5 marks.txt" displays column 5 and command "cut -d ' '-f3 marks.txt" displays column 3.

Next TopicLinux grep




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA