Bash – How to create a new empty file in a bash script

bashfilesshellshell-script

I'm running some third-party Perl script written such that it requires an output file for the output flag, -o.

Unfortunately, the script appears to require an actual file, that is, users must create an empty file filename.txt with 0 bytes and then input this empty file on the script command line

perl script1.pl -o filename.txt

Question: How would I create an empty file within a bash script? If one simply tries perl script1.pl -o filename.txt, the script gives an error that the file doesn't exist.

Best Answer

Use touch command. touch filename.txt.

Related Question