View Single Post
  #1 (permalink)  
Old 26-06-2009, 08:31 PM
jaysunn's Avatar
jaysunn jaysunn is offline
Powered By Linux
User
 
Join Date: Apr 2009
Location: 41.332032,-73.089775
OS: RHEL - OSX
Scripting language: BASH - Learning Ruby
Posts: 604
Thanks: 61
Thanked 80 Times in 72 Posts
Rep Power: 10
jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold jaysunn is a splendid one to behold
Default Alphabetize text within a file

Hello Forum people. I have been searching the Internet for the answer to my question, and I think it may be related to the command "sort" or "uniq"

In Example. I have a file with lines of text that are not in alphabetical order.

Code:
shine:~ jaysunn$ cat file1 
asdkfokaosfknksdigjisjigjdigjmnh

ojdfojjjojddfpdfo sdfokpoopsdf jsdfojsdf

wiewieiemd iuh asdlk  this is a file blah blah

shine:~ jaysunn$
What I would like to have happen is. I want to issue a command that will take the text within file1 and put it in alphabetical order from a-z. I am pretty sure that sort or uniq can achieve this. I have tried this and was unsuccessful. The command would alphabetize the text and output file2.

Code:
shine:~ jaysunn$ sort file1 | uniq -c > file2
   4 
   1 asdkfokaosfknksdigjisjigjdigjmnh
   1 ojdfojjjojddfpdfo sdfokpoopsdf jsdfojsdf
   1 wiewieiemd iuh asdlk  this is a file blah blah
shine:~ jaysunn$
Thanks in advance.

Jaysunn

Last edited by nixcraft; 02-07-2009 at 01:51 PM.
Reply With Quote