Solved

sed

Posted on 2000-05-10
7
563 Views
Last Modified: 2010-04-21
How would I if I had a file full of data seaperated by tabs, change this be be seperated
by a newline?
sed s/what is tab/what is newline/g kind of thing?
0
Comment
Question by:thedogeater
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 2

Expert Comment

by:jpmcgrath
ID: 2797290
To match a tab, you need to include an actual tab in your sed script.  To replace it with a newline, you need to include an actual newline, escaped by a '\'.

So the script would have the following characters:

  's' '/' TAB '/' '\' NL  '\' 'g' NL
  73  2f  09  2f  5c  0a  2f  67  0a


0
 

Author Comment

by:thedogeater
ID: 2797375
I do not understand your answer.
it is not right?

anyway thankytou
0
 
LVL 2

Accepted Solution

by:
jpmcgrath earned 100 total points
ID: 2797481
What's not to understand?  I gave you the script that you wanted, character for character.  The line following the script is the HEX values.

Since I cannot enter a TAB character into this editor, I have replaced each TAB with a '@' in the following.

The script would look like the following in a text editor:

s/@/\
/g

If you want to use it inline in a shell script, that would obviously depend on your shell.  But this would work in most shells:

sed 's/@/\
/g' infile > outfile

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:meerak
ID: 2797548
If you are having problems in entering a tab character from the
shell try <control v> <tab character>. (For eg. bash
does not allow to enter tab character.)
0
 
LVL 2

Expert Comment

by:jpmcgrath
ID: 2797592
I just noticed a typo in the original post.  It had a '\' instead of '/', although the hex code for the character was correct.  It should have been:

  's' '/' TAB '/' '\' NL  '/' 'g' NL
  73  2f  09  2f  5c  0a  2f  67  0a
0
 

Author Comment

by:thedogeater
ID: 2797621
Adjusted points from 50 to 100
0
 

Author Comment

by:thedogeater
ID: 2797622
I shoul have seen that too but I am to sleepy
must go to bed  anyway thaks for the help and more poing why not!

thaks
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Linux performance issues with 100% swap usage, etc 15 105
Invalid password trying to cannect to Unix server 2 107
Solaris 10.  Nmap installation fails 2 84
Solaris acount issues 44 75
When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question