reconstructing a record in a diffrent order


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers reconstructing a record in a diffrent order
# 1  
Old 10-16-2003
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  
Old 10-16-2003
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

 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How To Arrange Record In A Special Order?

Hi All, I have following data to be arranged based on columnd 6: 0098442947 0098222107 0098442134 0098200179 0098441067 0098442744 0098443106 0098442746 0098321411 0098443111 0098456611 0098444570 0098456600 0098385750 0098200288 (3 Replies)
Discussion started by: angshuman
3 Replies

2. Filesystems, Disks and Memory

Reconstructing RAID

I am trying to reconstruct a failed 4 disk RAID5 Western Digital ShareSpace device using 3 of the 4 disks connected via USB to an Ubuntu 12.04 machine. I get what seems like a successful re-assemble from - mdadm --assemble --force /dev/md2 /dev/sde4 /dev/sdf4 /dev/sdg4 mdadm: /dev/md2 has... (6 Replies)
Discussion started by: tonyaldr
6 Replies

3. Shell Programming and Scripting

Sed diffrent replace by occurrence

I couldn't find the answer anywhere, so I hope you could help me. I need to change something like the following: something/bla/aaaa anything/bbb to: something --bla ----aaaa anything --bbb How do I do this? Is it possible with sed? I tried various patterns, but don't know how to... (5 Replies)
Discussion started by: Patwan
5 Replies

4. Solaris

Diffrent output in cron jobs

Hi, I have issue with cron. When i run script manually output is fine but when i add it to cron output file is not as same. both file attach some junk charecter comming in cron output. thanx Jignesh (5 Replies)
Discussion started by: jkmistry
5 Replies

5. Red Hat

samba fileshare across 2 diffrent workgroup

Hi im trying to configure samba on linux server so win client can access the shared files but my win client is on diffrent domain , we recently changed our domain name but not for certain servers... i guess the samba linux server is still part of our sub domain which is why i still can access... (4 Replies)
Discussion started by: halacil
4 Replies

6. UNIX for Advanced & Expert Users

How to remove duplicate lines of a record without changing the order

Hi all, I have to remove duplicate lines in a file without chainging the order.for eg if i have a record pqr def abc lmn pqr abc mkh hgf the output should be pqr def abc lmn mkh hgf (7 Replies)
Discussion started by: abhi.roy03
7 Replies

7. UNIX for Dummies Questions & Answers

change order of fields in header record

Hello, after 9 months of archiving 1000 files, now, i need to change the order of fields in the header record. some very large, space padded files. HEADERCAS05212008D0210DOMEST01(spacepadded to record length 210) must now be 05212008HEADERCASD0210DOMEST01(spacepadded to record length 210) ... (1 Reply)
Discussion started by: JohnMario
1 Replies

8. Programming

using a filepointer in a diffrent program

Hi ALL : consider the given 2 codes: //p1.c #include<stdio.h> FILE * fp; main() { pid_t pid; fp=fopen(".........."); // now i am transfering the control to a new process(p2.c). pid=fork(); if(pid==0) ..... execl(" p2".....); .... ... (6 Replies)
Discussion started by: bankpro
6 Replies

9. UNIX for Advanced & Expert Users

Diffrent IP range connectivity

Hi guys, We have different IP ranges in our LAN, for instance my system IP Add. is in 163.183.37.x range, in the meantime i wish to connect to our printer/plotter which is 163.183.4.x & our LAN in another location with 163.183.38.x. What shoul i do except defining pesudo IP Add's? as a... (1 Reply)
Discussion started by: nikk
1 Replies

10. UNIX for Dummies Questions & Answers

Diffrent versions of Unix/Linux

With so many diffrent flavors out there, how is a person soposed to know what to go with? I'm not asking for specific discussion here in this forum, but I would like to see various pages and articles dicsussing the pluses and minuses of various unix/linux OS's. I have been searching various... (1 Reply)
Discussion started by: MorderKartoffel
1 Replies
Login or Register to Ask a Question