Sorting content of file

hi ladies and gents:

can you give me a command to sort content of file and save it to the file itself:

file1

roy@emerson.com
joy@emerson.com
irish@emerson.com

output would be file1 on same directory:

file1:

irish@emerson.com
joy@emerson.com
roy@emerson.com
 
sort input >output

it doesn't work redirecting the output on the same file.

sort < input > output; mv output input

based on "what" you are doing sort here?

It's true that "irish" comes first before "joy"!!! (input file itself is sorted)

oh sorry .. just overlooked it :slight_smile:

---------- Post updated at 08:25 PM ---------- Previous update was at 08:09 PM ----------

i need one liner sort command for this

TEST>perl -e '{open (F,"input_file");my @n_s=<F>;close(F);@s=sort(@n_s);open(F,">","input_file");foreach(@s) { print F "$_"; } close(F)}' input_file

Make sure the above works good only for "Alphanumeric" and not for others.

You need to enhance the script, if it needs to work for others.