sh script & files

Polytropon freebsd at
Wed Feb 20 12:46:41 UTC 2013

On Wed, 20 Feb 2013 07:40:08 -0500, Fbsd8 wrote:
> # write to file
>  > "${file}"
> I'm thinking the file is never closed so on power failure I loose the 
> contents of the file.
> How would I code a command to close the file?

The file is closed when the write operation has been
finished. You can use the "sync" command to flush
pending writes to the file (as writing is handled
asynchronously by the system). When the program
that writes to the file exits, it will close the
file it's writing to. This depends on the command
you're using infront of >, as the command you've
shown will simply generate a null file (file with
no actual content).

Magdeburg, Germany
Happy FreeBSD user since 4.0
Andra moi ennepe, Mousa, ...

More information about the freebsd-questions mailing list