File Viewing & Editing

cut

Remove sections from each line of input by column position or delimiter.

Synopsis

syntax
cut OPTION... [FILE]...

Examples

Extract columns 1 and 3 from CSV
cut -d',' -f1,3 data.csv
Extract first 10 characters of each line
cut -c1-10 file.txt
Get first directory in PATH
echo $PATH | cut -d: -f1
Remove first field from each line
cut -d' ' -f2- log.txt

Common options

FlagDescription
-dField delimiter (default: TAB)
-fSelect fields by number
-cSelect characters by position
-bSelect bytes by position
--complementInvert selection

About cut

The `cut` command remove sections from each line of input by column position or delimiter. Text viewing and editing commands are fundamental tools in any Linux user's toolkit.

Linux treats almost everything as a file, so the ability to quickly inspect, filter, transform, and edit file contents from the command line is critical. These commands are regularly combined with pipes and redirects to build powerful data-processing pipelines.

The command accepts 5 commonly used flags shown above, though the full set of options is available in the man page (`man cut`). The 4 examples on this page cover typical real-world usage patterns that you can copy and adapt for your own workflows.

Related commands

More File Viewing & Editing Commands

Other commands in the File Viewing & Editing category

Related tools