Empty file creation

From Linux Shell Scripting Tutorial - A Beginner's handbook
Jump to: navigation, search
← Standard errorHome/dev/null discards unwanted output →

  • To create empty file use the following syntax:
  • > 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:
# SCSI tape device
# Backup dir names
BDIRS="/www /home /etc /usr/local/mailboxes /phpjail /pythonjail /perlcgibin"
# Logfile name
# Remove old log file and create the empty log file
# Okay lets make a backup

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
← Standard errorHome/dev/null discards unwanted output →