I'd like to save a large amount data ( ~ 100MB ) from the standard input in temporary location for the duration of my bash session.

Piping it to a file won't work as I have only 30MB of free space. I also don't want to save it in a variable.

I'd obviously have to utilize some space other than that of my Disk Storage. Which leaves my RAM.

Is there some mechanism that will allow me to write to it, and then to retreive the written data again. ( like when you pipe to and from /dev/null )

  • It appears you want to do this from a shell. Also, do you want the data to be locked in ram? That is to NEVER get swapped out? – kbyrd Sep 16 '10 at 15:58
  • @kbyrd, updated the question, hope it makes more sense now :) – Stefan Sep 16 '10 at 16:31
  • 1
    I'm unclear about how krissi's answer doesn't address this. His answer provides a mechanism for writing to ram. – Steven D Sep 16 '10 at 16:43

you can mount an ramfs and store data there (as a file)

# mkdir /media/ram
# mount -t ramfs none /media/ram
# <texfile grep pattern > /media/ram/ram
# cat /media/ram/ram
# umount /media/ram
  • Stefan: this sounds like exactly what you're looking for - /media/ram will act like a device (like /dev/null), and will take up no disk space: any files you create in that directory will only be created "in memory" (i.e. in your RAM), and will be lost when you unmount /media/ram in the last step. – Gaurav Sep 16 '10 at 17:50
  • and thus it has been accepted – Stefan Sep 16 '10 at 19:04

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.