Technical article 105239

Trying to append to a file that doesn't exist, the error "No such file or directory" occurs.

OpenServer 5.0.0

Written · Last revised

Problem

I am trying to use the >> redirection to append to a file.
I issue the command:
echo stuff >> notthere

If the file doesn't exist, I get the error:

notthere: No such file or directory
This only happens when I use the csh(C).  I have set noclobber.

Solution

This is the way noclobber is designed to work in csh(C). Setting this option will prevent you from overwriting a file that exists, and also from appending to a file that doesn't exist.

There are 3 options:
(1) You can unset noclobber.  This will also allow files to be
    overwritten using >
(2) You can use >>! to append.  This overrides noclobber for
    this command only.
(3) You can use the ksh(C).  In ksh(C) you can set noclobber
    to prevent overwriting files, but still create new files
    using append.
Note: in 2.x releases of SCO UnixWare, csh(1) does _not_ work
as designed, and the non-existing file will be created and
appended to when using >> .  Please see IT/os 3016 for more
information.

From the Xinuos technical article database, record 105239. Reproduced with permission. The original is at www.sco.com/ta/105239, which is reachable but blocked from search engines. Xinuos marks this article against a retired product line. That refers to the product’s lifecycle, not to whether the advice still works — plenty of it still applies to running systems.

Next step

Need this fixed rather than explained?

Tell us the release, what the system runs and what it is doing. We will reply by email with what we would do next.

  • You deal with the people who do the work
  • No obligation, and no upgrade required before we will help
  • We tell you plainly if something is not worth doing

Send an enquiry

We reply by email. If a server is down, say so in the first line. You can also write to help@scoexpert.com.