set output delimiter as tab in cut command

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers set output delimiter as tab in cut command
# 1  
Old 12-28-2011
set output delimiter as tab in cut command

I can not make it work, it prints \t rather than introduce tabs.

cut -d "," -f 4,8 Samples.csv --output-delimiter="\t" |  sort > out

Since I am running this command within a shell script, I tried manually inserting tab in this command, still does not work. I am using bash shell
Suggestions highly appreciated
# 2  
Old 12-28-2011
Give a try to :
awk -F, '{print $4,$8}' OFS="\t" Samples.csv | sort > out

... by the way you can also have a look at:
man sort

it should be an option to specify a delimiter.
# 3  
Old 12-28-2011
Thanks for reply, this command works.
However, I am still curious why \t does not work with --output-delimiter flag with cut command. Does not matter if I pipe it with sort or not.
# 4  
Old 12-28-2011
I suppose it may depend on you cut implementation as well as on your shell options.
# 5  
Old 12-28-2011
An alternative:
cut -d, -f4,8 Samples.csv | tr -s ',' '\t' | sort > out

# 6  
Old 12-28-2011
You need to use the real tab character, not the two bytes backslash t. In bash type Ctl-v Tab inside the quotes.
# 7  
Old 12-29-2011
i am curious, why the below option doesn't work in cut.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Cut command with dynamic passing of delimiter and position values

Hi All, We have a requirement of picking nth position value by using cut command. value would be delimited by any symbols. We have to pass delimited value and postition to get the value in a string. ex. echo "A,B,C,D,E" |cut -d "," -f3 echo "A|B|C|D|E"|cut -d "|" -f2 Kindly frame the... (5 Replies)
Discussion started by: KK230689
5 Replies

2. Shell Programming and Scripting

Problem in using cut command with pipe as a delimiter while using in a script

There is a text file in my project named as "mom.txt" in which i want to have contents like.................. LSCRM(Application Name): 1: This is my first application. 2: Today we did shell scripting automation for this app. 3: It was really a good fun in doing so. 4: Really good.| (Here i... (7 Replies)
Discussion started by: Abhijeet Anand
7 Replies

3. Shell Programming and Scripting

How to combing output of cut commands with a delimiter?

While looping through a file, I am cutting different length of characters (based on their length) like columns and want to produce the output in a separate file with different columns being separated by a comma. How to achieve this with an online command. I don't want to create multiple variables... (8 Replies)
Discussion started by: mady135
8 Replies

4. Shell Programming and Scripting

How to set output delimiter?

Hello,All Suppose I have a file like following: aaa;bbb;ccc ddd;eee;fffI want the output like: aaa|bbb|ccc ddd|eee|fffTo do this, i wrote the code: awk 'BEGIN{FS=";";OFS="|"} {print}' myfileHowever, the output is still using ; as the delimter. What did I do wrong? Thanks. (5 Replies)
Discussion started by: littlewenwen
5 Replies

5. UNIX for Dummies Questions & Answers

LINUX - How to remove the final delimiter from a command output

Hi All, I am trying to list the various dates for which the file is available in a directory using the command below, (& subsequently pass the command output to a loop) Command : ls dir|grep 'filename'|cut -d '_' -f1|cut -c1-8|tr '\n' ',' However, it is giving me an extra comma... (6 Replies)
Discussion started by: dsfreddie
6 Replies

6. Shell Programming and Scripting

How to cut by delimiter, and delimiter can be anything except numbers?

Hi all, I have a number of strings like below: //mnt/autocor/4313'(33")W/ and i'm trying to get the numbers in this string, for example 431333 please help thanks ahead (14 Replies)
Discussion started by: sunnydanniel
14 Replies

7. Shell Programming and Scripting

CUT command delimiter in reverse

Hi, I've a situation where, a=xxx.yyy.zzz.txt EXTN=`echo $a | cut -d . -f2` Using the above code it delimites and will return "yyy.zzz.txt" to EXTN. But i need to get only the extension "txt". so as per the above code it delimits in the first "." itself. Can anyone help how to do... (6 Replies)
Discussion started by: skcvasanth
6 Replies

8. Shell Programming and Scripting

processing tab-formated output of command w/bash

I have a command that when ran it will have an output such as string LongerString string2 longerString2 More MoreStrings seperated by tabs. The command lists domains and their accounts set up in my server admin software (interworx). The end result will be that it will run rsync for... (2 Replies)
Discussion started by: sweede
2 Replies

9. UNIX for Advanced & Expert Users

How can I use double character delimiter in the cut command

Hi All, Can the cut command have double character delimiter? If yes, how can we use it. if my data file contains : apple || mango || grapes i used cut -f1 -d"||" filename but got an error. Plz help.... Thanks. (1 Reply)
Discussion started by: AshishK
1 Replies

10. Shell Programming and Scripting

Dynamic delimiter in cut command

hello.. my prob is as follows: i have to read from a file which may have different formats depending upon the delimiter used in the data of the i need that the user input the delimiter.the input delimiter is stored in a variable and is used on cut command to retrieve necessary... (3 Replies)
Discussion started by: tej.buch
3 Replies
Login or Register to Ask a Question

Featured Tech Videos