I have this command locally:

  nc localhost 3440 | tar -x -O > ores.tgz

if I receive one file from the server, it will be written to ores.tgz in my pwd.

However, if I receive multiple files from the server, it looks like only the last file I receive will be saved to the file, probably overwriting all of the previous ones.

So my question is - is there some way to save multiple files to different filenames in my pwd, using a similar command?


You can save it with timestamp suffix in this manner:

nc localhost 3440 | tar -x -O > ores-$(date +%s.%N).tgz

It will produce files with names like this:


Of cause you can remove nanosecond precision (%N) if your intensity of download isn't high.

  • wow I never would have thought that would be the way to do it! – Alexander Mills May 15 '18 at 0:04
  • I wonder how why this works under the hood – Alexander Mills May 15 '18 at 0:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.