[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#26279: sort bug
From: |
Michael Speer |
Subject: |
bug#26279: sort bug |
Date: |
Tue, 28 Mar 2017 09:30:24 -0400 |
This isn't a bug in sort. The ">" redirection operator in your shell opens
and truncates the file to ready it for output before your shell invokes
sort. After sort starts running and opens and reads the foo.txt file, it
finds that empty file and outputs nothing, as you would expect if you had
purposely given an empty file to sort.
You'll need to use a temporary file in order to avoid this.
sort foo.txt > foo.txt.tmp ; mv foo.txt.tmp foo.txt
On Tue, Mar 28, 2017 at 7:13 AM, Ismael Cama <address@hidden>
wrote:
> When you try to sort a file and write the result in the same file, all the
> contents are deleted. Example:
>
> sort foo.txt > foo.txt
>