Tab delimiter to ""


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Tab delimiter to ""
# 1  
Old 03-24-2010
Tab delimiter to ""

May be it's simple. But asa new bie I'm having hard time.

input : a tab delimited file
Code:
col    c1    c2    c3
a    X/X    Y/Y    D/D
b    L/L    L/L    M/M

output
Code:
col    c1    c2    c3
"a"    "X/X"    "Y/Y"    "D/D"
"b"    "L/L"    "L/L"    "M/M"

# 2  
Old 03-24-2010
one way:

Code:
#  sed '2,$s/\([^       ]*\)/\"\1\"/g' infile
col     c1      c2      c3
"a"     "X/X"   "Y/Y"   "D/D"
"b"     "L/L"   "L/L"   "M/M"

NOTE - the [^ ] is the following sequence:

[
^
ctrl-v
tab
]

hope that makes sense and helps
# 3  
Old 03-24-2010
Code:
sed '2,${s/^\|$/"/g;s/\([ \t]\+\)/"&"/g}' file

 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies

2. Open Source

Applescript if url of tab contains "text" click link

this works for what i need it to, but need to add function that will click on link if urloftab contains "300" the last url of each page ends in "300", so i figure that if I add a function that for every tab it open it will also search to see if url contains "300". if it contains "300" click link... (0 Replies)
Discussion started by: ilovedoritos
0 Replies

3. UNIX for Dummies Questions & Answers

Using "mailx" command to read "to" and "cc" email addreses from input file

How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address and column 3 contains “cc” e-mail address to include with same email. Sample input file, email.txt Below is an sample code where... (2 Replies)
Discussion started by: asjaiswal
2 Replies

4. Shell Programming and Scripting

Help -- Modify awk command to handle "," delimiter

Currently I am using this command to split a CSV file based on the distinct values in the 16th (position) column. awk -F, 'NR==1 { hdr=$0; next } $16 != prev { prev=name=$16; gsub(/_]/,"",name); $0 = hdr "\n" $0 } { print > ("/Directory/File."name".Download.csv") }'... (3 Replies)
Discussion started by: lojkyelo
3 Replies

5. Shell Programming and Scripting

Scripting to fix the issue in UNIX file having delimiter "|"

hello All, I am new user to shell scripting, kindly advise on the below? I have a file where i have gaps & the delimiter falls in next line and new line is also created , plz see the example :employee.txt Now the issue here is , i wan to write a script , where i can use "|" to get the... (6 Replies)
Discussion started by: sunnyd1
6 Replies

6. Shell Programming and Scripting

Substituting comma "," for dot "." in a specific column when comma"," is a delimiter

Hi, I'm dealing with an issue and losing a lot of hours figuring out how i would solve this. I have an input file which looks like this: ('BLABLA +200-GRS','Serviço ','TarifaçãoServiço','wap.bla.us.0000000121',2985,0,55,' de conversão em escada','Dia','Domingos') ('BLABLA +200-GRR','Serviço... (6 Replies)
Discussion started by: poliver
6 Replies

7. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

8. UNIX for Dummies Questions & Answers

Encoding Problem while using "|" (PIPE) as delimiter from Mainframe to Unix

We are facing a problem with PIPE (|) as a delimiter in one of our FTP flat files. We are constructing a Flat file in IBM-AIX and this contains various strings delimted by PIPE Symbol and then FTPing this to a Mainframe System The Mainframe program simply recieves this and FTPs the same... (1 Reply)
Discussion started by: seshendra
1 Replies

9. UNIX for Dummies Questions & Answers

Explain the line "mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`"

Hi Friends, Can any of you explain me about the below line of code? mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'` Im not able to understand, what exactly it is doing :confused: Any help would be useful for me. Lokesha (4 Replies)
Discussion started by: Lokesha
4 Replies
Login or Register to Ask a Question