cat command

Im in the terminal and Im in the directory within the terminal as well as the folder that I want to be in using finder. I can see the file that I would like to have displayed. So I run the command

cat Bits_and_Bytes.rtfd and it says no such file exist. So I try

cat Bits and Bytes.rtfd and it says no such file exist. Then I try

cat Bits and Bytes and it says no such file exist.

cat Bits_and_Bytes and it says no such file exist


I've tried the command with

less and nothing.


What am I doing wrong?


and I'm new to scripting in Linux


iMac 21.5″, 13.0

Posted on Dec 20, 2022 5:54 PM

Reply
Question marked as Top-ranking reply

Posted on Dec 21, 2022 6:33 AM

Your Bits_and_Bytes.rtfd file is a Rich Text package folder containing a TXT.rtf file and any images associated with this Apple-only specialty document. You cannot use the UNIX cat command on a folder, but you can do the following which will allow you to page through the legible plain text of TXT.rtf inside that document folder minus all of the RTF formatting strings:


textutil -stdout -convert txt Bits_and_Bytes.rtfd/TXT.rtf | more


3 replies
Question marked as Top-ranking reply

Dec 21, 2022 6:33 AM in response to DroidWRKMAC

Your Bits_and_Bytes.rtfd file is a Rich Text package folder containing a TXT.rtf file and any images associated with this Apple-only specialty document. You cannot use the UNIX cat command on a folder, but you can do the following which will allow you to page through the legible plain text of TXT.rtf inside that document folder minus all of the RTF formatting strings:


textutil -stdout -convert txt Bits_and_Bytes.rtfd/TXT.rtf | more


Dec 23, 2022 5:27 PM in response to DroidWRKMAC

Also, if there are spaces in a path, then you must either enclose the path in double-quotes, or you must escape the spaces by placing a backslash before the space. For example, either of these are acceptable:


cat  "Bits and Bytes.txt"

cat  Bits\ and\ Bytes.txt


The "less" command is a good option for displaying text files on the command line as you can use the up & down arrow keys to scroll through the text. To exit the display of text, just press the "q" key. "cat" is better used within scripts or multi-part commands with pipes.


You can also start typing the path, then press the Tab key to auto fill the path until the system finds multiple options. Pressing Tab twice will show you all of the options. Just type a character(s) to once again make a unique name where pressing Tab will auto fill as much as it can until another unique character must be entered.


Or with macOS you can just drag & drop the item from the Finder onto the open Terminal window which will auto fill the correct path to that item for you.


If you are going to be using the command line a lot, then I suggest you create folders & file names without using any spaces as it will greatly simplify things for you. I personally like to use the underscore character, although I will also use a hyphen as well for some situations.


If you are using the command line on both macOS and Linux, then you will usually find the Linux utilities have much newer versions with a lot more capabilities than the macOS couter parts which are usually using very old outdated versions of the utilities.

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

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