Solved

SED script

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

Accepted Solution

by:
tfewster earned 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
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…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

910 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

20 Experts available now in Live!

Get 1:1 Help Now