Solved

SED script

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Why Shell Scripting? Shell scripting is a powerful method of accessing UNIX systems and it is very flexible. Shell scripts are required when we want to execute a sequence of commands in Unix flavored operating systems. “Shell” is the command line i…
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 find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

821 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