![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | 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. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Sort file alphabetically AND numerically | mrodrig | UNIX for Dummies Questions & Answers | 2 | 05-19-2008 09:46 AM |
| How to sort alphabetically after finding values | doubleminus | UNIX for Dummies Questions & Answers | 4 | 04-28-2008 06:45 AM |
| Need to serach if a new line character exists on the last line in a file | sunilbm78 | UNIX for Dummies Questions & Answers | 10 | 02-29-2008 02:15 PM |
| Appending the line number and a seperator to each line of a file ? | pjcwhite | Shell Programming and Scripting | 4 | 03-21-2007 01:29 AM |
| Remove header(first line) and trailer(last line) in ANY given file | madhunk | Shell Programming and Scripting | 2 | 03-13-2006 03:36 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Sort a file line by line alphabetically
infile:
z y x c b a desired output: x y z a b c I don't want to sort the lines into this: a b c x y z nor this: c b a z y x The number of fields per line and number of lines is indeterminate. The field separator is always a space. Thanks for the use of your collective brains. ![]() |
|
||||
|
I've studied the sort docs and tried many combinations without success.
sort I'm sure I could muddle my way through with a python script, but I was hoping to get a one-liner using a "sort" or similar utility. This exercise is really just a puzzle I came up with while reading the Vim docs on filters. I was trying to sort a range of lines, then I asked myself if I could just sort the current line. I'm not a student in any classes, just a student of life. |
|
||||
|
you should show how you did that.
anyway, have a go at it Code:
awk '
{
for(i=NF;i>0;i--){
# fill in the blanks
}
}
' file
|
| Sponsored Links | ||
|
|