sed

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?
thedogeaterAsked:
Who is Participating?
 
jpmcgrathConnect With a Mentor Commented:
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
 
jpmcgrathCommented:
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
 
thedogeaterAuthor Commented:
I do not understand your answer.
it is not right?

anyway thankytou
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
meerakCommented:
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
 
jpmcgrathCommented:
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
 
thedogeaterAuthor Commented:
Adjusted points from 50 to 100
0
 
thedogeaterAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.