Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use space as a delimiter with cut command

Tags:

bash

unix

cut

I want to use space as a delimiter with the cut command.

What syntax can I use for this?

like image 681
Jaelebi Avatar asked May 03 '09 11:05

Jaelebi


People also ask

How do you give a space as delimiter in cut command?

\s* - delimiter.

How do you specify a space as a delimiter?

A space-delimited list is a kind of list (not a kind of space). It is a list which is delimited by spaces. The items x, y, and z have spaces between them: these spaces are the delimiters in the list. Likewise the list "x,y,z" is a comma-delimited list (it is in comma-delimited format).

Can space be used as delimiter?

Delimited formats Any character may be used to separate the values, but the most common delimiters are the comma, tab, and colon. The vertical bar (also referred to as pipe) and space are also sometimes used.

What is the default delimiter for cut?

The tab character is the default delimiter of cut, so by default, it considers a field to be anything delimited by a tab. Remember that the "space" between each word is actually a single tab character, so both lines of output are displaying ten characters: eight alphanumeric characters and two tab characters.


1 Answers

cut -d ' ' -f 2 

Where 2 is the field number of the space-delimited field you want.

like image 137
RichieHindle Avatar answered Sep 20 '22 02:09

RichieHindle