From: superpollo on 21 May 2010 09:34 hi. is it possible to crete a "text file" such that it has a different content each time it is opened? such as: <sample> $ cat text this is content $ cat text this is different $ cat text more different content </sample> and so on. bye
From: Bit Twister on 21 May 2010 10:05 On Fri, 21 May 2010 15:34:04 +0200, superpollo wrote: > hi. > > is it possible to crete a "text file" such that it has a different > content each time it is opened? such as: > ><sample> > $ cat text Only if you write a program and replace cat with your new program.
From: Ben Finney on 21 May 2010 10:25 superpollo <utente(a)esempio.net> writes: > is it possible to crete a "text file" such that it has a different > content each time it is opened? Not as a text file. Two existing patterns that I can think of: * Write a program to generate the output. Run that program. * Write a program to generate the output on a named pipe (see the Linux man page 'fifo(7)', or any Unix documentation about FIFOs). Run that program. Read the named pipe when you want the output. -- \ “The right to search for truth implies also a duty; one must | `\ not conceal any part of what one has recognized to be true.” | _o__) —Albert Einstein | Ben Finney
From: superpollo on 21 May 2010 10:43 Ben Finney ha scritto: > superpollo <utente(a)esempio.net> writes: > >> is it possible to crete a "text file" such that it has a different >> content each time it is opened? > > Not as a text file. > > Two existing patterns that I can think of: > > * Write a program to generate the output. Run that program. > > * Write a program to generate the output on a named pipe (see the Linux > man page 'fifo(7)', or any Unix documentation about FIFOs). Run that > program. Read the named pipe when you want the output. > ok, i tried this: $ cat fifo.sh #!/usr/bin/env bash [ -p "numbers" ] || mkfifo "numbers" for i in $(seq 1 1 10) do echo $i >> numbers done $ ./fifo.sh & [1] 7946 $ cat numbers 1 2 3 4 5 6 7 8 9 10 [1]+ Done ./fifo.sh $ but i expecter something like: $ cat numbers 1 $ cat numbers 2 $ cat numbers 3 ....
From: Ed Morton on 21 May 2010 11:15 On 5/21/2010 9:43 AM, superpollo wrote: > Ben Finney ha scritto: >> superpollo <utente(a)esempio.net> writes: >> >>> is it possible to crete a "text file" such that it has a different >>> content each time it is opened? >> >> Not as a text file. >> >> Two existing patterns that I can think of: >> >> * Write a program to generate the output. Run that program. >> >> * Write a program to generate the output on a named pipe (see the Linux >> man page 'fifo(7)', or any Unix documentation about FIFOs). Run that >> program. Read the named pipe when you want the output. >> > > ok, i tried this: > > > $ cat fifo.sh > #!/usr/bin/env bash > [ -p "numbers" ] || mkfifo "numbers" > for i in $(seq 1 1 10) > do > echo $i >> numbers > done > $ ./fifo.sh & > [1] 7946 > $ cat numbers > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10 > [1]+ Done ./fifo.sh > $ > > but i expecter something like: > > $ cat numbers > 1 > $ cat numbers > 2 > $ cat numbers > 3 > ... change ">>" to ">"
|
Next
|
Last
Pages: 1 2 Prev: Why am I still being prompted for a password? Next: What am I missing here? |