Search

tempfile to create temporary files in llinux

While running certain scripts we might need to create temporary files. To ease the creation of temporary files we can make use of the command



it creates an empty file with the name or with the required sufix and prefix. The default permissions for the file are 0600 that is read, write permission only for the creator.

Examples



The -n option is used to pass the name of the temporary file. The "-d ." indicates that the temporary file needs to be created in the current folder itself. We can pass a path to any folder in which we want the temporary folder.

Instead of a name of a file we can pass a suffix to the filename using -s



We can add a prefix using the option -p



Thus we can see that the the new file has been created with a suffix temp. But the user name is randomly chosen by the system. We can not choose the name of the file with -n option if we want to specify the suffix or prefix. If -n is passed the -s and -p, for prefix, are ignored.


Follow by Email