Hi Terry,
> > could try running `konsole' in that to see if any messages give a
> > clue.
>
> Well I got Konsole up and running with some errors being logged. I
> can't work out how to capture the messages to put them here. There is
> quite a bit.
If you're running a command, e.g. ls(1), then
ls foo nonexist >foo
re-directs standard output to the file ./foo, replacing any existing
contents and creating the file if it doesn't exist. Standard error
still goes to the default, the terminal.
ls foo nonexist >foo 2>bar
stdin is file descriptor 0, stdout is 1, stderr 2. For `>', a `1' is
implicit before it. You can specify something else. Here, I'm
re-directing stderr to file ./bar.
The traditional way of putting both to the same file is
ls foo nonexist >foo 2>&1
Order is significant. This changes stdout, 1, to be ./foo and *then*
changes stderr, 2, to be a duplicate of 1. bash provides a short-cut,
ls foo nonexist &>foo
Getting the order "wrong",
ls foo nonexist 2>&1 >foo
makes stderr a duplicate of stdout, currently the terminal, and then
makes stdout go to ./foo. Sometimes, that's what you want.
Don't do
sort foo >foo
since the shell handles re-direction, opening and truncating foo, before
it starts sort(1). sort sees an empty foo, sorts it, and exits without
error. Obviously, this applies to things other than sort too.
Cheers,
Ralph.
--
Next meeting: C4L and Bournemouth, Wednesday 2010-06-02 19:00
http://dorset.lug.org.uk/ http://www.linkedin.com/groups?gid=2645413
Chat: http://www.mibbit.com/?server=irc.blitzed.org&channel=%23dorset
List info: https://mailman.lug.org.uk/mailman/listinfo/dorset