![]() |
|
|
|
|
|||||||
| 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 |
| change order of fields in header record | JohnMario | UNIX for Dummies Questions & Answers | 1 | 05-22-2008 11:58 AM |
| how to read record by record from a file in unix | raoscb | UNIX for Dummies Questions & Answers | 1 | 05-16-2008 03:30 AM |
| splitting a record and adding a record to a file | rsolap | Shell Programming and Scripting | 1 | 08-13-2007 10:58 AM |
| using a filepointer in a diffrent program | bankpro | High Level Programming | 6 | 02-16-2006 09:11 AM |
| Diffrent IP range connectivity | nikk | UNIX for Advanced & Expert Users | 1 | 09-01-2003 08:33 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
reconstructing a record in a diffrent order
Can sed be used to take a existing record and reverse the order of defined character placement if there is no delimeters?
existing record: 0123456789CO expected result: 9876543210CO if there were delimeters I could define the delimeter and each placement would have an id which I could reconstruct by using the print $ command but without delimeters how do you assign the pacemnet ot a variable? Thanks |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
That would be a lot of work in sed. Here is a ksh solution:
Code:
#! /usr/bin/ksh
x="0123456789CO"
y=${x%??}
save=${x#${y}}
newy=""
while ((${#y})) ; do
tempy=${y%?}
char=${y#${tempy}}
y=$tempy
newy=${newy}${char}
echo $y $char $newy
done
x=${newy}${save}
echo $x
exit 0
|
||||
| Google The UNIX and Linux Forums |