Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to sort words in raw? 1

Status
Not open for further replies.

ogniemi

Technical User
Nov 7, 2003
1,041
PL

and how to test if words / columns in raw are identical?

thx.!
 
Have you looked at the man pages for sort and/or uniq ?

I hope that helps.

Mike
 
Mike ,

is it really possible to sort words in row using sort?


I mean, for example:

c b a g

and get in the result:

a b c g
 
echo 'c b a g' | tr ' ' '\n' | sort | tr '\n' ' '

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
vlad,

and how to proceed with multiple rows (file with multiple rows)?

thx,!
 
Code:
#!/bin/ksh

inputFile='og.txt'

while read line
do
 echo "${line}" | tr ' ' '\n' | sort | tr '\n' ' '
 echo ''
done < "${inputFile}"

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
thx vlad,

i though there is some oneliner as well for this operation.... but script is also ok.

thx.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top