I was sorting a very big file using Linux sort command and unfortunately the sort failed as there was not enough space on my /tmp directory.
$ sort -t “|” -k5 ka.log.32323112.out > ka.log.32323112.out
sort: /tmp/sort1928700448: write error: No space left on device
just to mention, sort by default uses /tmp for temporaries.
So, how you can tell sort to use some other directory for temporaries ?
From man pages of sort(1)
-T, –temporary-directory=DIR
use DIR for temporaries, not $TMPDIR or /tmp; multiple options specify multiple directories
$ sort -T /home/jadu/ -t “|” -k5 ka.log.32323112.out > ka.log.32323112.out
It worked 🙂
Another way would be : export env variable TMPDIR to some directory which have sufficient space.
e.g.
$ export TMPDIR=/path/to/other/directory
$ sort -t “|” -k5 ka.log.32323112.out > ka.log.32323112.out
It worked too 🙂
Recent Comments