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 03:58 PM
how to read record by record from a file in unix raoscb UNIX for Dummies Questions & Answers 1 05-16-2008 07:30 AM
splitting a record and adding a record to a file rsolap Shell Programming and Scripting 1 08-13-2007 02:58 PM
using a filepointer in a diffrent program bankpro High Level Programming 6 02-16-2006 12:11 PM
Diffrent IP range connectivity nikk UNIX for Advanced & Expert Users 1 09-02-2003 12:33 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-16-2003
r1500 r1500 is offline
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
  #2 (permalink)  
Old 10-16-2003
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
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

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:14 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0