Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SED script

Posted on 2004-09-27
4
Medium Priority
?
262 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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

670 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