Solved

SED script

Posted on 2004-09-27
4
227 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 20

Expert Comment

by:tfewster
Comment Utility
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
Comment Utility
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 20

Accepted Solution

by:
tfewster earned 500 total points
Comment Utility
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
Comment Utility
Thanks I think that will do what I need,

Thanks,  again
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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 …
Let's say you need to move the data of a file system from one partition to another. This generally involves dismounting the file system, backing it up to tapes, and restoring it to a new partition. You may also copy the file system from one place to…
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 navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

772 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

10 Experts available now in Live!

Get 1:1 Help Now