Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cut command with special characters

Status
Not open for further replies.

w33mhz

MIS
May 22, 2007
529
US
I am trying to run a cut and delimination is a tab. How do i us that in the cut command

usage i.e
Code:
for i in $(cat test.tmp | cut -d '\t' -f2)

This just gives me an error of :
cut: the deliminator must be a single character

So obviously my usage is wrong, can anyone please tell what the correct syntax?
 
Also I have tried the following

Code:
for i in $(cat test.tmp | cut -d \t -f2)

and that seems to run but the output doesn't seem correct.
 
Just type a 'tab' key between the '' quotes.

Also, no need for cat:

Code:
for i in $(cut -d '	' -f2 test.tmp)

Annihilannic.
 
I think the shell will interpolate the \t only if it is in double quotes. Try
Code:
for i in $(cat test.tmp | cut -d [red]"[/red]\t[red]"[/red] -f2)
(untested)

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top