0

In this command :

cut -f2 -d$'\t' 

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

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

0

1 Answer 1

2

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

Example:

$ printf '1234567*1234567*\na\thello\tthere\n'
1234567*1234567*
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.

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

Not the answer you're looking for? Browse other questions tagged .