willemdh
willemdh

Reputation: 856

Linux Bash - Write to log - No such file or directory

I would want to append a line to a logfile but I keep getting "No such file or directory"

cat "$NOW : Version $VERSION already installed on HOSTNAME!" >> /var/log/dig-nscp-install.log

I'm 100 % sure the file exists and it is writable when I nano it.

When i try it in cli,

cat 'Hellooo test'>>/var/log/dig-nscp-install.log

I also get cat: Hellooo test: No such file or directory

Any help / tips what I might be doing wrong?

thanks.

Upvotes: 1

Views: 4191

Answers (3)

damienfrancois
damienfrancois

Reputation: 59260

The error No such file or directory is about a hypothetical file named $NOW : Version $VERSION already installed on HOSTNAME!, not about /var/log/dig-nscp-install.log. As others have mentioned, use echo rather than cat as cat expects a file descriptor (e.g. a filename.)

echo "$NOW : Version $VERSION already installed on HOSTNAME!" >> /var/log/dig-nscp-install.log

Upvotes: 1

vahid abdi
vahid abdi

Reputation: 10308

you should use echo instead of cat

do this

echo "$NOW : Version $VERSION already installed on HOSTNAME!" >> /var/log/dig-nscp-install.log

Upvotes: 1

Mureinik
Mureinik

Reputation: 311988

cat outputs the content of a file. You should be using echo, which just echoes a string to stdout:

echo "$NOW : Version $VERSION already installed on HOSTNAME!" >> /var/log/dig-nscp-install.log

Upvotes: 3

Related Questions