Posted on April 30th, 2008 by linux
Using a bash command “set” we can prevent bash redirection to overwrite existing files. If the file bash.txt exist this command will overwrite it:
ls > bash.txt
To prevent it we can run command:
set -C
to disable run command:
set +o noclobber
Example:
$ ls > bash.txt
$ set -C
$ ls > bash.txt
bash: bash.txt: cannot overwrite existing file
$ [...]
Filed under: Bash, Linux, Scripting | No Comments »
Posted on April 28th, 2008 by linux
Here is a perl script example how to create temporary file on the file system:
TEMPLATE DIR AND SUFIX are option !
#!/usr/bin/perl
my $tempfile = new File::Temp ( TEMPLATE => ‘tempfile_XXX’, DIR => ‘/tmp/’, SUFIX => ” );
this will create a temporary file in /tmp/ directory with name tempfile_XXX where X is random generated character.
Filed under: Linux, Perl, Programming | No Comments »
Posted on April 28th, 2008 by linux
Here is a perl script example how to create temporary directory on the file system:
#!/usr/bin/perl
use File::Temp qw/ tempdir /;
my $perl_temporary_directory = tempdir();
Filed under: Linux, Perl, Programming | No Comments »