The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
delete \n character ReneVielma Shell Programming and Scripting 2 05-29-2008 03:46 PM
Korn: How to loop through a string character by character shew01 Shell Programming and Scripting 9 05-29-2008 06:47 AM
converting character string to hex string axes High Level Programming 5 09-20-2006 10:04 AM
Use sed to delete a character bthomas Shell Programming and Scripting 1 05-19-2005 12:21 PM
How to delete a character davidg UNIX for Advanced & Expert Users 3 02-19-2004 12:16 AM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1  
Old 09-28-2001
Registered User
 

Join Date: Sep 2001
Posts: 2
Delete first 2 character from string

Hi ! All,

I have to delete first 2 characters from string. How its possible?
Like string value is "2001". I required output as "01"

Plaese help me.


Nitin
Forum Sponsor
  #2  
Old 09-28-2001
PxT's Avatar
PxT PxT is offline
Registered User
 

Join Date: Oct 2000
Location: Sacramento, CA
Posts: 909
echo $string | sed 's/^..//'
  #3  
Old 10-01-2001
Registered User
 

Join Date: Sep 2001
Posts: 2
Quote:
Originally posted by PxT
echo $string | sed 's/^..//'
Very Very Thanks.

But I have required that resulted substring ("01"), be store in a variable. So that I can use it in a script.


Nitin
  #4  
Old 10-01-2001
Registered User
 

Join Date: Sep 2001
Posts: 1
I could give you C code if it helps...

int i;
for (i = 0; i < strlen(string)-1; i++)
(*string+i) = *(string+i+2);

PS To store the output from the above post, just do this:
string = $string | sed 's/^..//'

Last edited by Xenogenesis; 10-01-2001 at 03:56 AM.
  #5  
Old 10-02-2001
Registered User
 

Join Date: Oct 2001
Location: San Francisco
Posts: 27
Try:

substring=`echo $string | sed 's/^..//'`

- dEvNuL
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 09:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0