Reputation: 23
I perform a tail on 3 files and then create a new file, when I go to sort this new file it says it cannot be accessed. So in the code $a,$b and $c are text files. So how can i get this to sort the new file?
tail -q -n -5 $a $b $c > file.txt
sort file.txt -o file.txt
Upvotes: 0
Views: 2651
Reputation: 360153
What version of sort
? For GNU coreutils 7.4 it works for me.
If you were doing
sort file.txt > file.txt
it wouldn't work because the redirection would truncate the file before sort
read from it. However, when I do an strace
, it reveals that sort -o
doesn't write to the output file until the end.
Upvotes: 1