![]() |
Ciao e benvenuto da parte degli Stati Uniti al UNIX e Linux Forum! Grazie per la visita ed unirsi alla nostra Comunità Globale.
|
|
google unix.com
|
|||||||
| Forum | Registrati | Regole Forum | Collegamenti | Album | FAQ | Members List | Calendario | Ricerca | Today's Posts | Mark Forums Read |
| Shell scripting e di programmazione Pubblica domande su KSH, CSH, SH, Bash, Perl, PHP, sed, awk e da altri script di shell e linguaggi di scripting shell qui. |
Più di UNIX e Linux Forum Argomenti potreste trovare utili
|
||||
| Filo | Thread Starter | Forum | Risposte | Ultimo Post |
| Trova e sostituisci | NycUnxer | UNIX for Dummies Domande & Risposte | 4 | 03-06-2008 12:20 AM |
| trovare sostituire | dbsurf | Shell scripting e di programmazione | 2 | 01-25-2008 08:39 AM |
| trovare e sostituire | mahabunta | UNIX for Dummies Domande & Risposte | 7 | 09-21-2006 12:05 PM |
| trovare e sostituire | vikas_j @ hotmail | UNIX for Dummies Domande & Risposte | 3 | 02-25-2002 05:41 PM |
| Trova & Sostituisci | gagansharma | Shell scripting e di programmazione | 3 | 11-27-2001 04:17 PM |
|
|
LinkBack | Thread Tools | Cerca in questo Thread | Rate Thread | Modalità di visualizzazione |
|
||||
|
trovare e sostituire del problema
Hi guys!
Sto scrivendo uno script in cui prendo un input da un utente e di trovare in un file e sostituirlo. Il mio file di input somiglia Codice:
hi what your name? allrise Codice:
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
Codice:
hi what your name? hello $name Codice:
hi what your name? hello john |
| Segnalibri |
| Thread Tools | Cerca in questo Thread |
| Modalità di visualizzazione | Vota questo thread |
|
|