Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SED script

Posted on 2004-09-27
4
Medium Priority
?
270 Views
Last Modified: 2010-04-21
I have a line in a perl script that looks like this

sed -e '/[Pp]roduct [Vv]ersion/!d' -e 's/[^0-9]//g'`_ides.zip"         ( need to modify this line )


right now it takes from this:  Product version : 3.86.0
and give back this:             3860_ides.zip

I need it to give back this:    386_ides.zip


is there a way to modify this line to get the correct results.


Thanks
0
Comment
Question by:bt707
  • 2
  • 2
4 Comments
 
LVL 21

Expert Comment

by:tfewster
ID: 12161330
To just remove ".0" from the end of a line:  sed -e 's/\.0$//'

But what if it's "3.86.1"?  Or "4.0?" If you can show all the "variants" we may be able to describe a generic rule.

In this case, the whole sed statement would be:
sed -e 's/\.0$//' -e '/[Pp]roduct [Vv]ersion/!d' -e 's/[^0-9]//g'
0
 

Author Comment

by:bt707
ID: 12161559
Thanks for the info:

your right the number will change and that will mess me up latter on, could be only a matter of days.

What it is i need to do is not just drop the 0, i need to take the first 3 numbers and drop the '.' that is in between the firt two.
and also drop any thing that is after the first 3 numbers.


that way it always comes out like     386_ides.zip


Thanks, I hope this better explains what I need to do.
0
 
LVL 21

Accepted Solution

by:
tfewster earned 2000 total points
ID: 12161744
I think this does what you want:
sed -e 's/\.[0-9]*$//' -e '/[Pp]roduct [Vv]ersion/!d' -e 's/[^0-9]//g'

The 's/\.[0-9]*$//' strips off the last digits at the end of a line
0
 

Author Comment

by:bt707
ID: 12161961
Thanks I think that will do what I need,

Thanks,  again
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
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.
Suggested Courses
Course of the Month8 days, 19 hours left to enroll

877 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