![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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
|
||||
|
||||
|
echo $string | sed 's/^..//'
|
|
#3
|
|||
|
|||
|
Quote:
But I have required that resulted substring ("01"), be store in a variable. So that I can use it in a script. Nitin |
|
#4
|
|||
|
|||
|
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
|
|||
|
|||
|
Try:
substring=`echo $string | sed 's/^..//'` - dEvNuL |
|||
| Google The UNIX and Linux Forums |
| Thread Tools | |
| Display Modes | |
|
|