![]() |
Olá e boas-vindas de Estados Unidos para o UNIX e Linux Forum! Obrigado por visitar e fazer parte da nossa comunidade global.
|
|
google unix.com
|
|||||||
| Fóruns | Registar | Fórum Regimento | Ligações | Álbuns | FAQ | Lista deputados | Calendário | Pesquisa | Today's Posts | Mark Forums Read |
| Programação Shell Script e Post perguntas sobre ksh, CSH, SH, BASH, Perl, PHP, SED, Awk e outros scripts shell e shell scripts línguas aqui. |
Mais UNIX e Linux Fórum Tópicos Você pode achar Helpfull
|
||||
| Fio | Thread Starter | Fórum | Respostas | Última postagem |
| Localizar e Substituir | NycUnxer | UNIX para Dummies Perguntas & Respostas | 4 | 03-06-2008 12:20 |
| encontrar substituir | dbsurf | Programação Shell Script e | 2 | 01-25-2008 08:39 |
| localizar e substituir | mahabunta | UNIX para Dummies Perguntas & Respostas | 7 | 09-21-2006 12:05 |
| localizar e substituir | vikas_j @ hotmail | UNIX para Dummies Perguntas & Respostas | 3 | 02-25-2002 05:41 |
| Localizar e Substituir | gagansharma | Programação Shell Script e | 3 | 11-27-2001 04:17 |
|
|
Linkback | Thread Tools | Pesquisar este Thread | Rate Thread | Display Modes |
|
||||
|
localizar e substituir problema
oi gente!
Estou escrevendo um script em que eu tome uma entrada do usuário e encontrá-lo em um arquivo e substituí-lo. O meu arquivo de entrada parece Código:
hi what your name? allrise Código:
echo "Enter the name"
read name
FILE="/opt/name.txt"
NEW_FILE="/opt/new_name.txt"
exec 0<$FILE
while read line
do
if [ -n "`echo ${line} | grep 'allrise'`" ]
then
echo ${line} | sed 's|allrise|hello $name|g' >>$NEW_FILE
else
echo $line >>$NEW_FILE
fi
done <$FILE
Código:
hi what your name? hello $name Código:
hi what your name? hello john |
| Marcadores |
| Thread Tools | Pesquisar este Thread |
| Display Modes | Esta taxa Thread |
|
|