Entra

View Full Version : sed


onos3nd4i
06-06-2004, 15:57
ciao a tutti.

ho una lista di frasi in un file. come faccio ad aggiungere per es. all'inizio di ogni riga del file:

quote1
quote2
quote3

etc?

grazie

gurutech
06-06-2004, 17:55
Cosė?

bash-2.05a$ cat pippo.txt
abc
dfgefd
derger
wergfe
bash-2.05a$ cat pippo.txt | grep -n . | sed -e "s/^\([0-9]*\):\(.*\)/Quote\1\ \2/"
Quote1 abc
Quote2 dfgefd
Quote3 derger
Quote4 wergfe


dai anche un'occhio qui
http://sitescooper.org/tao_regexps.html
http://sed.sourceforge.net/grabbag/tutorials/

e non dimenticare la bibbia
http://www.oreilly.com/catalog/covers/sed2.s.gif (http://www.oreilly.com/catalog/sed2/index.html)