Solved

sed

Posted on 2000-05-10
7
554 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
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ftpcommand 2 51
Oracle Finace 3 48
Using gawk to read and manipulate multiple texts from a file 1 40
Problem logging tar errors 11 36
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
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 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…
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…

743 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

14 Experts available now in Live!

Get 1:1 Help Now