hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Web Hosting Talk Tutorials : Programming Tutorials : Sed and pattern matching.
Reply

Forum Jump

Sed and pattern matching.

Reply Post New Thread In Programming Tutorials Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 09-25-2006, 04:06 PM
disruptive disruptive is offline
New Member
 
Join Date: Sep 2006
Posts: 0

Sed and pattern matching.


Hi I wish to alternately change some of the data in the following way. For example I wish to switch all species from their current value to their binary opposite. I.e. from 1 -> 0 and from 0 -> 1 when the LIPID number is even. Now the data is on the file such that the LIPID number is before the SPECIES number. Therefore I came up with the following sed script to attempt to do this. However this script doesńt work when there is information/data between the LIPID and the SPECIES but seems to work just fine otherwise. Here is the script and the data file:

LIPID 0
SPECIES 0
5435345
LIPID 1
SPECIES 1
435345.4544
LIPID 2
SPECIES 1
22.78
LIPID 3
SPECIES 1
22.78
LIPID 4
SPECIES 1
22.78
LIPID 5
SPECIES 1
LIPID 6
SPECIES 1

sed '
/[02468]$/ {N
s/SPECIES 1/SPECIES 0/
}' Test1.txt > OP.txt;
mv OP.txt Test1.txt;



Sponsored Links
Reply

Related posts from TheWhir.com
Title Type Date Posted
Boston University Receives $3 Million from Massachusetts for Open Public Cloud Marketplace Web Hosting News 2014-05-01 08:33:54
Cloud Storage Provider Box Buys dLoop for Greater Insight, Control over Content Web Hosting News 2013-11-27 12:59:56
Microsoft Embraces Enterprise Roots with Windows Azure IaaS Web Hosting News 2013-04-16 14:12:44
Superb Internet Introduces Price Match Guarantee for Hosting Services Web Hosting News 2013-03-22 12:36:38
Web Host AIS Launches AIS ClearCompute Life Sciences SaaS Platform Web Hosting News 2012-10-23 17:16:28


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:
WHT Membership
WHT Membership



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?