Can't cat a file or make a directory: contradictory output?

16,685

Solution 1

A "file" can be a couple of things. For example man find lists:

  -type c
          File is of type c:

          b      block (buffered) special
          c      character (unbuffered) special
          d      directory
          p      named pipe (FIFO)
          f      regular file
          l      symbolic link
          s      socket
          D      door (Solaris)

In your case that "file" might be a broken symlink or a regular file containing the text "no such file or directory".

You can use ls -ld sublime to find out. (The first character indicates the type of the file.)

Solution 2

If the file is not present, you can't do cat afile. You need cat > afile. However, in your case, it seems that the file sublime is present with the text content: no such file or directory. If the file would not be there the exact message would have been:

$ cat afile
cat: afile: No such file or directory

Solution 3

The sublime is probably a broken soft (symbolic) link to a removed file or directory. You can use ls -l to see what it is linked to. The broken links are usually highlighted in red in the ls output.

Share:
16,685

Related videos on Youtube

bernie2436
Author by

bernie2436

Updated on September 18, 2022

Comments

  • bernie2436
    bernie2436 over 1 year

    I am getting output from a terminal in Ubuntu 12 that I don't understand.

    $cat sublime
    no such file or directory
    
    $mkdir sublime
    cannot create directory 'sublime': File exists
    

    How can both of these be true? I am trying to install sublime text with these instructions but having trouble making a symbolic link because /usr/bin/sublime does not exist.

    • Rahul Patil
      Rahul Patil over 10 years
      may be sublime file contain no such file or directory unix prank :P, So try nl sublime or check with ls -thor