Solved

remove /n using sed

Posted on 2011-09-23
3
355 Views
Last Modified: 2012-06-22
Hi,

I have a text file like below,

team alpha 400
team bet/na 800
team ga/nmma 900
team omega 1100

I need to remove /n from above text using sed. I want the new lines to be preserved though.. (after the numbers). Can someone help..

lego..
0
Comment
Question by:legolasthehansy
3 Comments
 
LVL 16

Assisted Solution

by:medvedd
medvedd earned 250 total points
ID: 36586787
sed -e 's?/n??' <filein >fileout
0
 
LVL 76

Accepted Solution

by:
arnold earned 250 total points
ID: 36586897
If you do not alter the separator you use in sed as the example medvedd provided, you have to escape the '/' in '/n' which is done using the '\'
sed -e 's/\/n//' <filein >fileout

The separator can be almost any character as long as you use single quotes(') to enclose the pattern double quotes (") will have the shell process the contents and replace characters that have meaning $,!,etc.. (hedging since I have not tried all options)
0
 
LVL 11

Author Closing Comment

by:legolasthehansy
ID: 36587343
Thanks,

sed -e 's?\\n??' infile worked
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The purpose of this article is to demonstrate how we can use conditional statements using Python.
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
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…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 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

15 Experts available now in Live!

Get 1:1 Help Now