Variables in shell script not working
Jef Driesen
jefdriesen at hotmail.com
Sat Nov 15 17:01:21 UTC 2008
Karl Auer wrote:
> 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.
That did the trick!
Thanks everyone for the help.
More information about the ubuntu-users
mailing list