Solved

sed

Posted on 2000-05-10
7
557 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
  • 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
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.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SSH commands for Nas4free 21 416
AIX  NFS  question 1 136
Restore XenServer VM with only dd image of LVM snapshot 3 177
Convert OverPunch 25 63
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…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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.

816 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now