Re: How to suppress warning messages for empty lines in shell scripts?
- From: mop2 <invalid@xxxxxxxxxxxx>
- Date: Sat, 31 May 2008 16:09:58 -0300
On Sat, 31 May 2008 14:17:36 -0300, Jochen Berninger <buzzuz@xxxxxxxxxxx> wrote:
From the command line I called (with nohup) a shell script which contains empty lines
(for better readability).
The nohup executes the script successfully but outputs a warning for the empty line:
/usr/local/joch/bin/dotest: line 3:
: command not found
How can I suppress this warning (of cause without removing the empty line)?
Do I really have to always avoid empty lines in shell scripts?
Jochen
You can't use DOS style to end each line, in other words,
the line must be ended with NewLine, not "CarriageReturn+NewLine".
I think this is a possibility in your case.
See:
$ echo -e 'a \r\n\a\b\t b'|cat -A
a ^M$
^G^H^I b$
$
"\r" is a carr.ret. showed as "^M" through cat.
In your script you can test if there are CRs with:
$ cat -A yourScript
Or, if your script is large, with grep's help:
$ cat -A yourScript|grep \\^M
You can see any ^M?
If yes, this can be the problem.
Look for lines with ^..., without characters, they
are viewed possibly as empty lines in an editor.
.
- Prev by Date: Re: How to suppress warning messages for empty lines in shell scripts?
- Next by Date: Re: What means "*/5" in crontab file?
- Previous by thread: Re: How to suppress warning messages for empty lines in shell scripts?
- Next by thread: Re: How to suppress warning messages for empty lines in shell scripts?
- Index(es):
Relevant Pages
|