![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | 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 !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Counting position of a character | rochitsharma | UNIX for Advanced & Expert Users | 3 | 11-27-2007 06:26 PM |
| Change Position of word character | cedrichiu | Shell Programming and Scripting | 6 | 03-12-2007 01:52 AM |
| How to add character in specific position of a string? | victorlung | Shell Programming and Scripting | 5 | 09-01-2006 11:33 AM |
| Finding character position in file | dhananjaysk | Shell Programming and Scripting | 5 | 03-23-2006 11:49 AM |
| Character position | akrathi | UNIX for Dummies Questions & Answers | 4 | 10-26-2005 05:06 AM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How to split a value according to character position
Hello all,
I have a script which picks up a series of large numbers, each of which are actually amalgamations of a series of other numbers. Unfortunately there are no separator characters so I can't use awk -F. I am looking for a way of splitting them into variables according to their character position. For example: 123456789 I would like to split this into a number of variables according their character position in the value, for example: var1=12 var2=345 var3=678 var4=9 Is there a simple way of splitting a value according to character position with sed or some other program for example? Many thanks. |
|
||||
|
Many thanks for the prompt response and advice. I have tried this and get the following back: Code:
number=123456789
echo ${number:0:2}
0403-011 The specified substitution is not valid for this co
mmand.
echo ${number:3:4}
0403-011 The specified substitution is not valid for this co
mmand.
Is there an environmental variable or specific shell I need in order to enable this feature with the echo command? Although there may be a number of files to process, I am currently picking them up using a for loop and putting them into a variable to process here. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|