{"id":6910,"date":"2017-08-24T17:55:37","date_gmt":"2017-08-24T09:55:37","guid":{"rendered":"http:\/\/rmohan.com\/?p=6910"},"modified":"2017-08-24T17:56:03","modified_gmt":"2017-08-24T09:56:03","slug":"changing-temporary-directory-for-sort-bash","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6910","title":{"rendered":"Changing temporary directory for sort &#8211; bash"},"content":{"rendered":"<p><strong>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.<\/strong><\/p>\n<p>$\u00a0sort -t &#8220;|&#8221; -k5 ka.log.32323112.out &gt; ka.log.32323112.out<br \/>\nsort: \/tmp\/sort1928700448: write error: No space left on device<\/p>\n<p>just to mention, sort by default uses \/tmp for temporaries.<\/p>\n<p>So, how you can tell sort to use some other directory for temporaries ?<\/p>\n<p>From man pages of sort(1)<\/p>\n<p>-T, &#8211;temporary-directory=DIR<br \/>\nuse DIR for temporaries, not $TMPDIR or \/tmp; multiple options specify multiple directories<\/p>\n<p>$\u00a0sort -T \/home\/jadu\/ -t &#8220;|&#8221; -k5 ka.log.32323112.out &gt; ka.log.32323112.out<\/p>\n<p>It worked \ud83d\ude42<\/p>\n<p>Another way would be : export env variable TMPDIR to some directory which have sufficient space.<\/p>\n<p>e.g.<\/p>\n<p>$\u00a0export TMPDIR=\/path\/to\/other\/directory<br \/>\n$\u00a0sort -t &#8220;|&#8221; -k5 ka.log.32323112.out &gt; ka.log.32323112.out<\/p>\n<p>It worked too \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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.<\/p>\n<p>$ sort -t &#8220;|&#8221; -k5 ka.log.32323112.out &gt; ka.log.32323112.out sort: \/tmp\/sort1928700448: write error: No space left on device<\/p>\n<p>just to mention, sort by default uses \/tmp for temporaries.<\/p>\n<p>So, how [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6910"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6910"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6910\/revisions"}],"predecessor-version":[{"id":6912,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6910\/revisions\/6912"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6910"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6910"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}