Empty file creation
From Linux Shell Scripting Tutorial - A Beginner's handbook
- To create empty file use the following syntax:
>newfile.name
- > operator redirects output to a file. If no command given and if file doesn't exist it will create empty file. For example, create a shell script called tarbackup.sh:
#!/bin/bash TAR=/bin/tar # SCSI tape device TAPE=/dev/st0 # Backup dir names BDIRS="/www /home /etc /usr/local/mailboxes /phpjail /pythonjail /perlcgibin" # Logfile name ERRLOG=/tmp/tar.logfile.txt # Remove old log file and create the empty log file >$ERRLOG # Okay lets make a backup $TAR -cvf $TAPE $BDIRS 2>$ERRLOG
Notice you can also use touch command for empty file creation:
touch /tmp/newtextfile
Save and close the file. Run it as follows:
chmod +x tarbackup.sh ./tarbackup.sh