Variables in shell script not working
kauer at biplane.com.au
Sat Nov 15 15:41:13 GMT 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
> 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.
Karl Auer (kauer at biplane.com.au) +61-2-64957160 (h)
http://www.biplane.com.au/~kauer/ +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: not available
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/ubuntu-users/attachments/20081116/e783d986/attachment.pgp
More information about the ubuntu-users