"cat" command fails to create a usable txt file. Is there something I need to make sure of?

What could be causing my new combined files to be created as 0 byte empty files? I saved them as UTF-8. Is that wrong?

MacBook Pro 13″, macOS 11.5

Posted on Sep 28, 2021 5:24 AM

Reply
1 reply

Sep 28, 2021 6:01 AM in response to pablohp

If you are still in the Bash 3 shell, you can create an empty file by the following commands in the Terminal:


>foo.txt

or

touch foo.txt

or

echo "" > foo.txt

or

cat /dev/null > foo.txt


All but the first example work in the Zsh shell. Ordinarily, on a UNIX system, one does not use cat in this manner to create an empty file, but rather the touch command. The cat command is more for concatenating n-tuple files into a final file, or reviewing the content of an existing text file for bogus line endings, to name a couple of usages.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

"cat" command fails to create a usable txt file. Is there something I need to make sure of?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.