Re: valtozo helyettesites
#!/bin/bash . f1.sh echo Van $alma db almam es echo $korte db kortem. ==%%== $ ./f2.sh Van 1 db almam es 3 db kortem. vagy nem ertek valamit? ebben a file-ban nincsenek echo-k tusi _ linux lista - linux@mlf.linux.rulez.org http://mlf2.linux.rulez.org/mailman/listinfo/linux
Re: valtozo helyettesites
Gabor Tusnady wrote: Hogyan tudom bash scrittel eloallitani azt a file-t, amiben a file2-ben levo valtozokat a file1-ben szereplo ertekekkel helyettesiti? $ cat file1 alma=1 korte=3 $ cat file2 Van $alma almam es $korte kortem. $ cat korlevel #! /bin/sh if [ $# -ne 2 ]; then echo Usage: ${0##*/} valtozo-file szoveg-file /dev/stderr exit 1 fi TEMPFILE=$(mktemp -qt ${0##*/}.XX) || TEMPFILE=/tmp/${0##*/}.$$ { echo cat EOF cat $2 echo EOF } $TEMPFILE . $1 . $TEMPFILE rm -f $TEMPFILE $ ./korlevel file1 file2 Van 1 almam es 3 kortem. -- Sziasztok: Zsolt _ linux lista - linux@mlf.linux.rulez.org http://mlf2.linux.rulez.org/mailman/listinfo/linux
Re: valtozo helyettesites
In article 1269875240.23837.6.ca...@botond.simon.enzim.hu, Gabor Tusnady t...@enzim.hu writes: Van egy file-om amiben kulonbozo valtozok vannak definialva: file1: alma=1 korte=3 ... Van egy masik file-om, amibe meg ezek a valtozok valamilyen modon szerepelnek: file2: Van $alma db almam es $korte db kortem. Hogyan tudom bash scrittel eloallitani azt a file-t, amiben a file2-ben levo valtozokat a file1-ben szereplo ertekekkel helyettesiti? eredmeny_file: Van 1 db almam es 3 db kortem. $ cat korlevel.sh #!/bin/sh . file1 lo=`cat file2` eval echo \$lo\ $ ./korlevel.sh Van 1 db almam es 3 db kortem. $ Hátránya: 1-2 kB-nál nagyobb file2-re már nem lesz jó. g _ linux lista - linux@mlf.linux.rulez.org http://mlf2.linux.rulez.org/mailman/listinfo/linux
Re: valtozo helyettesites
Gabor Tusnady t...@enzim.hu writes: file1: alma=1 korte=3 ... file2: Van $alma db almam es $korte db kortem. eredmeny_file: Van 1 db almam es 3 db kortem. $ { cat file1; echo cat EOF; cat file2; echo EOF; } | sh eredmeny_file _ linux lista - linux@mlf.linux.rulez.org http://mlf2.linux.rulez.org/mailman/listinfo/linux
Re: valtozo helyettesites
Koszonom mindegyik valaszt, sokat tanultam beloluk. Legjobban ez tetszett: { cat file1; echo cat EOF; cat file2; echo EOF; } | sh eredmeny_file tusi _ linux lista - linux@mlf.linux.rulez.org http://mlf2.linux.rulez.org/mailman/listinfo/linux
Re: valtozo helyettesites
Gabor Tusnady t...@enzim.hu writes: Kedves Lista! Valami nagyon egyszerut szeretnek csinalni: Van egy file-om amiben kulonbozo valtozok vannak definialva: file1: alma=1 korte=3 ... Van egy masik file-om, amibe meg ezek a valtozok valamilyen modon szerepelnek: file2: Van $alma db almam es $korte db kortem. $ . file1 $ cat file2 | while read l; do eval echo $l; done De ezzel nagyon vigyazz az eval miatt. Vilmos _ linux lista - linux@mlf.linux.rulez.org http://mlf2.linux.rulez.org/mailman/listinfo/linux