Sort -u problem
I am trying to use the sort -u command in backtrack but I have a problem.

I run backtrack from a flash drive and I would like to remove duplicates from a 3.5GB file residing on an external hard drive. My flash drive has only 400MB left free space and whenever I try to sort the file on the external hard drive it stops and tells me I have run out of space.

This is because the temp file is being written to my local flash drive and not to the larger external drive which has many GB's of free space.

I tried using the (Action open command prompt here) within the external drive in the hope that is where backtrack would then write the temp file. Unfortunately this didn't happen.

Does anyone know how I can make it so the temp file is written to the external drive and not the flash drive ?


You can use the -T switch. See: sort --help.
Hi San thanks for your help !

I am trying that switch now, I thought it would be something to do with the OS and not directly related to the sort command, I feel stupid now.

It doesn't seem to work for me. Sad

Here is what I am trying.

test.txt is the text file to sort.

testsorted.txt is the text file I want to finish up with.

newtempfolder is where I would like the new temp files putting.

I try...

sort -T 'media/truecrypt4/words/newtempfolder' -u 'media/truecrypt4/words/test.txt' > 'media/truecrypt4/words/testsorted.txt'

I have a mounted truecrypt volume with everything in it. I know the path names are correct as I dragged them in so I couldn't mistype anything.

Nothing seems to happen.

I even changed this bit 'media/truecrypt4/words/newtempfolder/' to have a forward slash, still nothing.
you forgot the leading slash. it should be "/media/" not "media/". "media/" would point to some directory like /your/current/working/path/media/...". Also make sure your external drive is not mounted read-only.
Thanks for that undeath, you are of course correct, unfortunately it was a fault of my post and not of the actual code I used but very well spotted though !

Well its finally working and I think this has been one of those "comedy of errors" things !

I have never used this command before and I perhaps should have practiced on something smaller and simpler for my first go, but tonight I was in a "death or glory" sort of mood and I just went for it !! I am not certain of the order of events but in case anyone else here has any trouble here's what I think happened.

I tried to use the sort function and got my original crash (out of memory) due to my flash drive. After San's help I tried using the -T switch and I think I may have forgotten to change the name of the output folder. What I was doing was dragging them into the command screen to save typing and then I just re-name the end output file. I think on one occasion I must have forgotten this and totally wiped the original to 0 Bytes.

As the file was still there but there wasn't anything in it I was trying various commands and not getting an output, obviously because there was nothing in the input !! As I hadn't noticed this I was assuming things weren't working, but it may well have been doing so all along.

So thank to you both for your help. Entirely my fault.

The winning command was.... if anyone else needs it.

sort -T '/media/truecrypt4/words/newtempfolder' -u 'media/truecrypt4/words/test.txt' > media/truecrypt4/words/testsorted.txt

I must say this is taking an awfully long time to run, I normally use ULM as it is very good at this sort of thing but it does suffer from crashes when working with larger files. I hoped Ubuntu (Backtrack) would be better than windows for this and I await to see if it gets through it.