The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Sorting Files by date and moving files in date order rebel64 Shell Programming and Scripting 2 03-11-2008 12:45 PM
shell program for sorting strings in an alphabetical order bp_vanarse Shell Programming and Scripting 1 10-25-2006 10:41 AM
Where to Order 5.1L Cds slacker AIX 2 12-02-2005 06:53 AM
low-order seven bits solea UNIX for Advanced & Expert Users 2 10-06-2004 02:18 AM
Sorting filenames by order in another file samudimu UNIX for Advanced & Expert Users 4 05-24-2002 12:03 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 12-02-2005
evoGage evoGage is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 4
Order sorting

How do you sort text in order using sed?

For example

01 B D A C

to 01 ABCD
  #2 (permalink)  
Old 12-02-2005
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,796
I dont think sed alone has the power to do that.

But couple it along with other tools and it can be done.

The result follows the spacing pattern of the input.

Code:
[~/temp]$ echo "01 B D A C" | sed -e 's/ /\n/g' | sort | tr '\n' ' '
01 A B C D
  #3 (permalink)  
Old 12-02-2005
Raom Raom is offline
Registered User
  
 

Join Date: Sep 2005
Location: india
Posts: 79
Try this
echo "01 B D A C" | fold -2 |sort -b|xargs echo

Last edited by Raom; 12-02-2005 at 06:53 AM..
  #4 (permalink)  
Old 12-04-2005
grahamb grahamb is offline
Registered User
  
 

Join Date: Dec 2005
Location: Windsor, Ont Canada
Posts: 13
Quote:
Originally Posted by Raom
Try this
echo "01 B D A C" | fold -2 |sort -b|xargs echo
Hi
To get rid of the spaces then add:
Code:
.....  | sed 's/ //g'
echo "01 B D A C" | fold -2 |sort -b|xargs echo | sed 's/ //g'
Regards
GrahamB
Sponsored Links
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 04:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
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