[Bulma] Dudas de regexp, sed y awk
Mateu Mir
mateu.mir en gmail.com
Mie Abr 23 18:55:33 CEST 2008
Amb AWK ho pots fer de la seguent manera:
#!/bin/bash
i=1
for p1 in `awk '{print $1}' fitxer1`
do
echo -n $p1","`awk -v n=$i -F , '{print $n}' fitxer2 `":">>fitxer3
let i+=1
done
Pensa que nomes t'ho bé si hi ha el mateix nombre de paraules als
fitxers 1 i 2, o si 2 es més gran tampoc no fallara.
Salut!
2008/4/23 Sergi Barroso <hirorualionclan.org>:
> Gràcies Toni,
>
> Tot i que ha de ser estrictament amb sed o awk, ja que anirà a dins d'un
> script de bash.
>
> Merci
>
> # Amb python pots fer algo així de cutre
>
>
>
> #
> # fd0 = open("file0")
> # linies = fd0.read().split('\n')
> #
> # fd1 = open("file1")
> # paraules = fd1.read().split(',')
> #
> # l = " "
> # for i in range(len(paraules)):
> # l = l + paraules[i] + ',' + linies[i]
> #
> # print l
> #
> # Òbviament falten moltes coses, excepcions pels fitxers, veure que la
> # longitud de paraules i de linies coincideixi, etc ...
> #
> # Salut!
> #
> # --
> # "Two of the most famous products of Berkeley are LSD and Unix. I don't
> # think that this is a coincidence."
> # http://servomac.blogspot.com
> # _______________________________________________
> # Bulmailing mailing list
> # Bulmailingabulma.net
> # http://llistes.bulma.net/mailman/listinfo/bulmailing
> # Etiqueta: http://breu.bulma.net/?l676
>
> #
>
>
> --
> Sergi Barroso
> Linux user #313577
> PGPID: 287913B4
> http://www.lionclan.org
>
> _______________________________________________
>
>
>
> Bulmailing mailing list
> Bulmailingabulma.net
> http://llistes.bulma.net/mailman/listinfo/bulmailing
> Etiqueta: http://breu.bulma.net/?l676
>
Más información sobre la lista de distribución Bulmailing