Variables in shell script not working

Karl Auer kauer at biplane.com.au
Sat Nov 15 16:32:16 UTC 2008


On Sat, 2008-11-15 at 17:04 +0100, Jef Driesen wrote:
> The output should always go to stdout and when the script is used with
> a filename, the original should not be modified. So that excludes
> running dos2unix on it directly.

Try

   FILENAME=$1
   cat $FILENAME | dos2unix | sed s/foo/bar/ 

This will work even if there is no filename, because cat takes stdin if
no file is specified. If there is a filename, the named file will not be
modified.

Regards, K.

-- 
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20081116/9da931a1/attachment.sig>


More information about the ubuntu-users mailing list