The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Removing '." character using SED arvindcgi Shell Programming and Scripting 2 06-03-2008 07:28 AM
Removing character ' from a variable sertansenturk Shell Programming and Scripting 3 04-19-2008 08:53 AM
removing new line character ammu Shell Programming and Scripting 2 01-15-2008 10:12 AM
Removing first character in a string npn UNIX for Advanced & Expert Users 4 06-06-2006 07:02 AM
Removing the ^M character in VI julesinbath UNIX for Dummies Questions & Answers 2 04-29-2002 09:13 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-23-2007
Raynon Raynon is offline
Registered User
  
 

Join Date: Sep 2006
Location: Sg
Posts: 350
Removing a character using sed

Hi,

I have a file with the text below. How do i remove the character "%" from the text file using sed ? Can anybody help ?

0%
68%
72%
0%
54%
33%
75%
24%
6%
59%
77%
77%
33%
  #2 (permalink)  
Old 01-23-2007
Mark Thomas Mark Thomas is offline
Registered User
  
 

Join Date: Oct 2006
Location: Tampa, Florida
Posts: 14
Code:
sed 's/%//' file > newfile
  #3 (permalink)  
Old 01-23-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,509
basically, its just something like this
Code:
echo "68%" | sed "s/%$//" #assume % is always at the end.
  #4 (permalink)  
Old 01-23-2007
Raynon Raynon is offline
Registered User
  
 

Join Date: Sep 2006
Location: Sg
Posts: 350
You guys are great! It works !Thanks a million
  #5 (permalink)  
Old 09-17-2007
growler360 growler360 is offline
Registered User
  
 

Join Date: Sep 2007
Posts: 1
What if you could possibly have more than one % character at the end of the string? What command would you use then to ensure that there were no % chars at the end?

I ask b/c I want to take a directory path that a user passes me, and if there are any / chars at the end, I want to delete them all.


thanks to all for any help...
  #6 (permalink)  
Old 09-17-2007
robotronic's Avatar
robotronic robotronic is offline Forum Advisor  
Can I play with madness?
  
 

Join Date: Apr 2002
Location: Italy
Posts: 370
Quote:
What if you could possibly have more than one % character at the end of the string? What command would you use then to ensure that there were no % chars at the end?
Code:
echo "82%%%" | sed 's/%*$//'
Quote:
I ask b/c I want to take a directory path that a user passes me, and if there are any / chars at the end, I want to delete them all.
Code:
echo "/this/is/my/path////" | sed 's!/*$!!'
  #7 (permalink)  
Old 11-21-2008
JDkrishna80 JDkrishna80 is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 2
remove string contains /

How can remove string contains / in a file
for example my input like
<dgjfgjdgfjsdg/kdfhgdhgjkhdfjkg/jkdfjhdk/kjfdhgkdjh=kjfh:"dfjgdjfg"><dfjvgdjgvdjgfvjdgfjgdjfgjkdg><jdfgvjdgfjgbdjfgbj>

i would like to remove

<dgjfgjdgfjsdg/kdfhgdhgjkhdfjkg/jkdfjhdk/kjfdhgkdjh=kjfh:"dfjgdjfg">
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:29 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0