↑ ↓ select, Enter open, Esc close

Extract specific fields with cut

Adjust the values, the command updates live
user@server
cut -d':' -f1,7 /etc/passwd

Splits each line at the delimiter and prints only the requested fields. Fields can be given as a list (1,7), a range (2-4) or open-ended (3-). In the example, the username and login shell of all accounts are shown.

Note: cut only accepts a single character as delimiter and treats several consecutive spaces as several empty fields. For whitespace-separated output, awk '{print $2}' is better suited.

Also searched as

  • extract column from file linux
  • show only certain fields cut
  • split fields by colon

Related one-liners

All in Text processing

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.