0

I am new to linux and am trying to get to know the command line and I got to the cat command and am having trouble with an error message. I am not quite sure what is happening here. Every time I type cat to open a file I get cat: abod: No such file or directory. I am trying to open a file from LibreOffice using "cat blog.odt" Any body knows what I am doing wrong?

2
  • 2
    Can you edit your question to include the cat command you are using and the output?
    – troylatroy
    Oct 9, 2013 at 21:29
  • Be aware that odt files will contain markup. To view the file with an application that can format the markup, use gnome-open instead of cat
    – konapun
    Oct 9, 2013 at 23:32

3 Answers 3

1

I guess that simply means what it says, the file is not in the directory you are in. Check with ls -la and look for your file in the list it gives you. Also you can hit tab twice and get the choices you have and see if it's there. Plus, get ready to see lots of garbage, cat is not libreofice.

1
  • yes i just figured that out. I was trying to go from home to documents and had to go to the jp13 directory first. Thank you.
    – Billy
    Oct 9, 2013 at 23:49
0

You must either be "in" the directory of the file, or use the full path to the file when trying to cat it. Also cat does not open a file in libre office, unless there are some special options I am not aware of, all it will do is dump the contents of the file out onto the console. You can also use cat to add lines of text into a file but that is not what you are trying to do either.
Most likely you can just type libreoffice /home/$USER/path/to/blog.odt and that will open the file in libreoffice. Note that $USER needs to be replaced with your name if it is not set as an environment variable. And /path/to/blog.odt needs to be the path from your home folder, not your desktop, to where ever blog.odt is.
For example if it was in a folder called "blog_stuff" on your Desktop, and your username was bob, the command would look like libreoffice /home/bob/Desktop/blog_stuff/blog.odt
Let tab completion become your friend in this, that is hitting tab twice while typing a path, it will either auto complete or show you the list of possibilities that match what you have typed so far.

0

cat just prints the contents of a file to your terminal. Since ODT is a compressed format, you will not get any meaningful output using cat on those files.

I suspect that the command you are really looking for is xdg-open -- this will open the specified file with whatever the default application is set to for that file type. It's equivalent to double-clicking on a file in your GUI file manager. Use it like:

xdg-open file.odt
## or:
xdg-open /path/to/file.odt

...but make sure that you are in the correct directory. Also, for some bizarre reason xdg-open can only work on one file at a time, so you'll have to use a loop if you want to open multiple files, something like:

for f in file1.odt file2.pdf; do xdg-open "$f"; done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .