1
Is there way to do something like thas:
cat somefile.txt | sort | uniq > somefile.txt
I.e. I want to list entire file, then pipe some actions to its content and finally put result back to source file overwriting it completely. For now I doing it by putting output to temporary file and after all moving it over original. I want to do it such simple way like linux piping allows.
Shell is bash
in Linux and cmd
in Windows if it is important.
1
sponge
is the general answer, but sincesort
(unlike most utilities) needs to buffer all the data before outputting any (except for-m
), for this specific case you can insteadsort -u -o somefile.txt somefile.txt
. – dave_thompson_085 – 2016-04-13T03:56:48.130