Estoy haciendo un script en bash y necesito añadir un texto al final de
una linea determinada de un archivo.
Alguna idea?
Saludos
man sed(1)
sed -e 'IDENTIFICADOR_DE_LINEAs/$/NUEVO_TEXTO/' < in > out
> Saludos
>
--
Gonzalo Pérez de Olaguer Córdoba <gp...@iies.es>
PGP key 2861C704 --- F206 5671 6789 425D 111C 1302 214F 1934 2861 C704
Pues depende de cómo identifiques a la línea. Supongamos este fichero:
#v+
$ cat prueba.txt
Hola
Adios
#v-
Si quieres añadir "-un saludo" a la línea que dice Hola, puedes hacerlo
así:
#v+
ed prueba.txt <<"SCRIPT"
/Hola/s/$/-un saludo/
w
q
SCRIPT
#v-
Y ya está:
#v+
$ cat prueba.txt
Hola-un saludo
Adios
#v-
--
Si quieres que te sigan las mujeres, ponte delante.
--- Francisco de Quevedo ---
Si Dióxido de Silicio | Debian GNU/Linux
/ \ (SiO2) | José Miguel Sánchez Alés
O O Mineral de Cuarzo | sio2....@online.fr | URL #257033
speeter wrote:
> Estoy haciendo un script en bash y necesito añadir un texto al final de
> una linea determinada de un archivo.
echo "texto a añadir al final de la linea" >> ~/fichero.txt
- --
Esteban Navarro
Fondos de Escritorio:
http://scandisk.todofondos.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)
iD8DBQFAoTMCoVO1uCntWAwRAhCkAJ9lKeVCFjynJ0JVwOWQESSXxUbRGgCfadpv
Jc/x9FfCeDE5vnmjqUnNktA=
=9h0m
-----END PGP SIGNATURE-----
Esteban Navarro escribió en es.comp.os.linux.programacion:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> speeter wrote:
>
>> Estoy haciendo un script en bash y necesito añadir un texto al final de
>> una linea determinada de un archivo.
>
> echo "texto a añadir al final de la linea" >> ~/fichero.txt
¿Ya has probado eso que dices? (me da a mí que no).
--
SALUD,
Jesús
***
jesus_...@undominio.net
***
El Tue, 11 May 2004 22:09:38 +0200, Esteban Navarro escribió:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> speeter wrote:
>
>> Estoy haciendo un script en bash y necesito añadir un texto al final de
>> una linea determinada de un archivo.
>
> echo "texto a añadir al final de la linea" >> ~/fichero.txt
Jeje, creo que has hecho trampa. Eso te la añade al final del archivo,
no de una línea en concreto.
Para eso está sed(1). Es cojonudo para hacer este tipo de chorradillas.
Saludos
- --
Alberto Giménez, SimManiac en el IRC
http://www.almorranasozial.es.vg
GnuPG ID: 0x3BAABDE1
WinError 01E: Timing error - Please wait. And wait. And wait. And wait.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iD8DBQFAoV1P0keCtzuqveERAr91AJsFMV2RnKENmwqFdX7fWFGpO5TRBgCglNoU
fK4695o1wf4jzRnhHiW91CM=
=DSnc
-----END PGP SIGNATURE-----