I need to create a blank file in Linux. I know I can use cat and echo command as echo 'data' > file
but it will not create a blank file in Linux. Blank means zero size. File exists but zero size. How do I do that?
You can create an empty file from command line using various methods. Here is a quick summary:
1. Use touch command to create a blank file
touch filename
2. Use redirection
> filename
Want to append data and keep existing file? Try:
>> filename
echo 'data 2' >> filename
3. Use echo command to create a empty file
echo -n > filename
4. How to use printf to create a blank file
printf '' > filename
5. Use the ls command to verify it:
ls -l filename
OR
stat filename
The file size should be always zero (0). See