Help with converting Pipe delimited file to Tab Delimited


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with converting Pipe delimited file to Tab Delimited
# 1  
Old 02-01-2012
Question Help with converting Pipe delimited file to Tab Delimited

I have a file which was pipe delimited, I need to make it tab delimited. I tried with sed but no use

Code:
 
cat file | sed 's/|//t/g'

The above command substituted "/t" not tab in the place of pipe.

Sample file:
Code:
 
abc|123|2012-01-30|2012-04-28|xyz
 
have to convert to:
abc 123 2012-01-30 2012-04-28 xyz

Thanks!
# 2  
Old 02-01-2012
Code:
echo 'abc|123|2012-01-30|2012-04-28|xyz' | tr '|' '\t'

# 3  
Old 02-01-2012
Hi,
you can achieve that with the following code


Code:
$ cat file.txt | sed 's/|/\t/g'
abc     123     2012-01-30      2012-04-28      xyz


thanks,
venkat
# 4  
Old 02-01-2012
You get a useless use of cat award.

Code:
sed 's/|/\t/g' < file.txt

# 5  
Old 02-01-2012
Code:
# echo "abc|123|2012-01-30|2012-04-28|xyz" | sed 's/|/ /g'
abc 123 2012-01-30 2012-04-28 xyz


Last edited by Franklin52; 02-01-2012 at 04:06 AM.. Reason: Please use code tags for code and data samples, thank you
# 6  
Old 02-01-2012
Quote:
Originally Posted by aksijain
# echo "abc|123|2012-01-30|2012-04-28|xyz" | sed 's/|/ /g'
abc 123 2012-01-30 2012-04-28 xyz
He is looking for Tab Space and not Blank Space... hence

Code:
sed -e 's/|/\t/g' inputfile > outputfile

This User Gave Thanks to knight_eon For This Post:
# 7  
Old 02-01-2012
try this
Code:
echo "abc|123|2012-01-30|2012-04-28|xyz" | tr '|' '\t'

Output:
Code:
abc     123     2012-01-30      2012-04-28      xyz


Thanks,
Kalai

Last edited by Franklin52; 02-01-2012 at 08:00 AM.. Reason: Please use code tags for code and data samples, thank you
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Replace a column in tab delimited file with column in other tab delimited file,based on match

Hello Everyone.. I want to replace the retail col from FileI with cstp1 col from FileP if the strpno matches in both files FileP.txt ... (2 Replies)
Discussion started by: YogeshG
2 Replies

2. Shell Programming and Scripting

Convert pipe demilited file to vertical tab delimited

Hi All, How can we convert pipe delimited ( or comma ) file to vertical tab (VT) delimited. Regards PK (4 Replies)
Discussion started by: prasson_ibm
4 Replies

3. Shell Programming and Scripting

Help/Advise please for converting space delimited string variable to comma delimited with quote

Hi, I am wanting to create a script that will construct a SQL statement based on a a space delimited string that it read from a config file. Example of the SQL will be For example, it will read a string like "AAA BBB CCC" and assign to a variable named IN_STRING. I then concatenate... (2 Replies)
Discussion started by: newbie_01
2 Replies

4. UNIX for Dummies Questions & Answers

Need to convert a pipe delimited text file to tab delimited

Hi, I have a rquirement in unix as below . I have a text file with me seperated by | symbol and i need to generate a excel file through unix commands/script so that each value will go to each column. ex: Input Text file: 1|A|apple 2|B|bottle excel file to be generated as output as... (9 Replies)
Discussion started by: raja kakitapall
9 Replies

5. Shell Programming and Scripting

Oracle table extract: all columns are not converting into pipe delimited in flat file

Hi All, I am writing a shell script to extract oracle table into a pipe dilemited flat file. Below is my code and I have attached two files that I have abled to generate so far. 1. Table.txt ==> database extract file 2. flat.txt ==> pipe delimited after some manipulation of the original db... (5 Replies)
Discussion started by: express14
5 Replies

6. Shell Programming and Scripting

How to make tab delimited file to space delimited?

Hi How to make tab delimited file to space delimited? in put file: ABC kgy jkh ghj ash kjl o/p file: ABC kgy jkh ghj ash kjl Use code tags, thanks. (1 Reply)
Discussion started by: jagdishrout
1 Replies

7. Shell Programming and Scripting

How to convert a space delimited file into a pipe delimited file using shellscript?

Hi All, I have space delimited file similar to the one as shown below.. I need to convert it as a pipe delimited, the values inside the pipe delimited file should be as highlighted... AA ATIU2345098809 009697 005374 BB ATIU2345097809 005445 006518 CC ATIU9685098809 003215 003571 DD... (7 Replies)
Discussion started by: nithins007
7 Replies

8. Shell Programming and Scripting

Converting comma separated to pipe delimited file

Hi, I came across a very good script to convert a comma seperated to pipe delimited file in this forum. the script serves most of the requirement but looks like it does not handle embedded double quotes and commas i.e if the input is like 1234, "value","first,second", "LDC5"monitor",... (15 Replies)
Discussion started by: anijan
15 Replies

9. UNIX for Dummies Questions & Answers

Converting Space delimited file to Tab delimited file

Hi all, I have a file with single white space delimited values, I want to convert them to a tab delimited file. I tried sed, tr ... but nothing is working. Thanks, Rajeevan D (16 Replies)
Discussion started by: jeevs81
16 Replies

10. Shell Programming and Scripting

Converting Tab delimited file to Comma delimited file in Unix

Hi, Can anyone let me know on how to convert a Tab delimited file to Comma delimited file in Unix Thanks!! (22 Replies)
Discussion started by: charan81
22 Replies
Login or Register to Ask a Question