Sed ajout en fin de commande script shell
Résolu
titoulevrai
-
titoulevrai -
titoulevrai -
Bonjour,
Je travail sur un script et j'ai besoin en sed de rajouter en fin de ligne de chaque ligne de commande un "debug".
Je voudrai que le script:
Se transforme en:
Les difficultés principales que j'ai c'est la gestion de quillemets, les lignes vides et la gestion des commentaires.
Merci d'avance
Je travail sur un script et j'ai besoin en sed de rajouter en fin de ligne de chaque ligne de commande un "debug".
Je voudrai que le script:
echo lolpass1
ping 127.0.0.1 -c 2
echo testcom #commentaires
echo "test"
Se transforme en:
echo lolpass1 && echo "echo lolpass1 : OK" >>result.txt || echo "echo lolpass1 " >> $errors
ping 127.0.0.1 -c 2 && echo "ping 127.0.0.1 -c 2 : OK" >>result.txt || echo "ping 127.0.0.1 -c 2" >> $errors
echo testcom && echo "echo testcom: OK" >>result.txt || echo "echo testcom" >> errors.txt#commentaires
echo "test" && echo "echo "test" : OK" >>result.txt || echo "echo "test"" >> errors.txt
Les difficultés principales que j'ai c'est la gestion de quillemets, les lignes vides et la gestion des commentaires.
Merci d'avance
A voir également:
- Sed -n shell
- Classic shell - Télécharger - Personnalisation
- Secure shell - Télécharger - Divers Web & Internet
- Shell infrastructure host c'est quoi - Guide
- Shell startup windows 10 - Guide
- Efi shell version 2.31 - Forum Programmation
1 réponse
Salut,
;-))
$ cat brol
echo lolpass1
ping 127.0.0.1 -c 2
echo testcom #commentaires
echo "test"
$ sed "/^$/! s/^[^#]*/& \&\& echo '& : OK' >> result.txt || echo '&' >> errors.log/" brol
echo lolpass1 && echo 'echo lolpass1 : OK' >> result.txt || echo 'echo lolpass1' >> errors.log
ping 127.0.0.1 -c 2 && echo 'ping 127.0.0.1 -c 2 : OK' >> result.txt || echo 'ping 127.0.0.1 -c 2' >> errors.log
echo testcom && echo 'echo testcom : OK' >> result.txt || echo 'echo testcom ' >> errors.log#commentaires
echo "test" && echo 'echo "test" : OK' >> result.txt || echo 'echo "test"' >> errors.log
;-))
titoulevrai
Merci beaucoup!