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
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

Closed Thread
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-16-2003
Registered User
 

Join Date: Jun 2003
Posts: 10
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  
Old 10-16-2003
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
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
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 08:48 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