Variables in shell script not working
Carl Friis-Hansen
ubuntuuser at carl-fh.com
Sat Nov 15 16:55:16 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.
You are right, I only looked at the response to dos2unix -h. I tried it:
carl at cjfh3:~$ echo "Hi foo my friend" | cat | dos2unix | sed s/foo/bar/
Hi bar my friend
carl at cjfh3:~$
--
+---------------------------------+-------------------+
| Carl Friis-Hansen | Fiskeryd Nybygget |
| http://computingconfidence.com/ | 341 91 Ljungby |
| Phone: +46 (0)372 15033 | Sweden |
+---------------------------------+-------------------+
More information about the ubuntu-users
mailing list