Variables in shell script not working

Karl Auer kauer at
Sat Nov 15 15:41:13 UTC 2008

On Sat, 2008-11-15 at 16:20 +0100, Jef Driesen wrote:
> This is indeed the problem! At first, I only had the sed command,
> which does accept a filename AND outputs to stdout. I simply didn't
> think about this difference when adding the dos2unix command.
> Is it possible to have the pipe command in the variable, without cat 
> interpreting both the pipe symbol "|" and the "dos2unix" as its
> argument?
> SOURCE="cat $FILENAME | dos2unix"

Yes, that will work fine - but it doesn't run sed, and the output goes
to stdout rather than being saved in the original file.

This will convert the filename and (if the conversion worked) run it
through sed, sending the output to stdout:

   dos2unix $FILENAME && cat $FILENAME | sed s/foo/bar/

That's basically what Carl was saying, too.

But what is it you actually want to achieve here? The above will send
the sedded output to stdout after unixifying the specified file, but the
sedded output will not be saved in the file.
Regards, K.

Karl Auer (kauer at                   +61-2-64957160 (h)                  +61-428-957160 (mob)

GPG fingerprint: DD23 0DF3 2260 3060 7FEC 5CA8 1AF6 D9E3 CFEE 6B28

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <>

More information about the ubuntu-users mailing list