|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||
|
||||
|
Swapping a string of numbers between higher and lower order values(HEX)
I have this below string in a variable Code:
cutString=21222222222222222122222222222222 this string is nothing but hex values depicted as below Code:
21:22:22:22:22:22:22:22:21:22:22:22:22:22:22:22 so what i want to achieve is swap the lower order with higher order values in the string Code:
21222222222222222122222222222222 output: 12222222222222221222222222222222 let me give you another exaample Code:
12345678901234567890123456789012 output: 21436587092143658709214365870921 also i need to do one more implementation first i need to store this convertted output in one variable say nextString later i need to introduce a space between each byte as below so that i can loop it in for loop and perform some operation..(PS: there shouldnt be an extra space at the end of string) Code:
2 1 4 3 6 5 8 7 0 9 2 1 4 3 6 5 8 7 0 9 2 1 4 3 6 5 8 7 0 9 2 1 any help is deeply appreciated. thanks. even if i can just learn how to introucde spaces, i can handle swapping in for loop by myself. :-) |
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
or sth like this.. Code:
echo "12345678901234567890123456789012" | rev | sed 's/./& /g' |
|
#4
|
||||
|
||||
|
Thanks a lot Scrutinizer.. the command works good :-)
@pamu.. thanks but that code is reversing the whole string and not higher value to lower value. but thanks anyway :-) |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| swapping the values of variable! | nikki1200 | Shell Programming and Scripting | 5 | 12-22-2011 11:23 AM |
| Changing and swapping the Values in the files | polineni | Shell Programming and Scripting | 2 | 11-03-2011 08:22 AM |
| if test for higher value between 2 decimal numbers | emjs | Shell Programming and Scripting | 5 | 07-29-2011 09:05 AM |
| How to convert hex numbers to decimal ? | jack2 | Shell Programming and Scripting | 15 | 04-07-2009 09:24 AM |
| ksh and hex numbers | JamesByars | Shell Programming and Scripting | 2 | 01-15-2008 02:36 PM |
|
|