Operating System - HP-UX
1748038 Members
4990 Online
108757 Solutions
New Discussion юеВ

Re: how to remove percent sign at end of line

 
SOLVED
Go to solution
Rob Yohn
Advisor

how to remove percent sign at end of line

I have a file that contains percentage output and I would like to extract just the number without the percent sign. Here is a sample of what the file would contain.

94%
95%
93%
100%

How can I remove the "%" and just extract the number?
6 REPLIES 6
Pete Randall
Outstanding Contributor
Solution

Re: how to remove percent sign at end of line

Something like this maybe:

cat file |sed 's|%||g'


Pete

Pete
Tim Nelson
Honored Contributor

Re: how to remove percent sign at end of line

or

cat file|tr -d %

James R. Ferguson
Acclaimed Contributor

Re: how to remove percent sign at end of line

Hi Rob:

# sed -e 's/%//' file

Regards!

...JRF...
Rob Yohn
Advisor

Re: how to remove percent sign at end of line

Thanks all. That is exactly what I was looking for.

Rob Yohn
Advisor

Re: how to remove percent sign at end of line

Thanks for the quick response!
Points have been assigned.
Dennis Handly
Acclaimed Contributor

Re: how to remove percent sign at end of line

If you want to remove it only on the end of the line (and no whitespaces after it):
sed 's/%$//' file