Solved

sed

Posted on 2000-05-10
7
564 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

626 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