0

This question already has an answer here:

in this command :

cut -f2 -d$'\t' 

('\t') what is it mean ? i saw it another question, i got the idea about 'tap' delimiter but still want to know '\t' shortcut or sign or command for something

How to define 'tab' delimiter with 'cut' in BASH

marked as duplicate by muru, Community May 21 at 19:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

The horizontal tabulator character is a character that most often brings the cursor up to the next multiple of eight spaces when it's outputted.

Example:

$ printf '12345678901234567890\na\thello\tthere\n'
12345678901234567890
a       hello   there

As you can see above, for each tab character, the cursor is forwarded to the next multiple of eight spaces.

The tab character is written as \t in the C programming language. Printing a string containing \t with printf in the shell or with printf() in C (and in many other places) produces a horizontal tab character in place of the two characters \ and t.

In the bash shell, $'...' is a special "C escape string". Within it, escape sequences like \t (for tab) or \n (for newline) are treated just like in printf() in the C language. This is described in the bash manual in the section titled "QUOTING".

With cut -d $'\t' you tell cut to use tab as the delimiter when cutting the fields of the input data. However, this happens to be the default delimiter that cut will use if you don't use -d at all, so -d $'\t' is not needed in your command.

  • Straight to the Point, Well explained, thanks a lot, now i know, they are calling -Escape sequences- of course thanks to you – MAX LEARNING May 21 at 19:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.