PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > for shell
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

for shell

Réponse
 
LinkBack Outils de la discussion
Vieux 12/11/2007, 20h49   #1
astalavista
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut for shell

hi,

I need some for shell.
How can modify a file to get
the same lines appended
the same line with some pattern modified
(exemple below)

Thanks for your ...

before:
aaaazzzzaaaa
bbbbzzzzbbbb
cccczzzzcccc
ddddzzzzdddd


after:
aaaazzzzaaaa aaaayyyyaaaa
bbbbzzzzbbbb bbbbyyyybbbb
cccczzzzcccc ccccyyyycccc
ddddzzzzdddd ddddyyyydddd



  Réponse avec citation
Vieux 12/11/2007, 23h19   #2
Janis Papanagnou
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: for shell

astalavista wrote:
> hi,
>
> I need some for shell.
> How can modify a file to get
> the same lines appended
> the same line with some pattern modified
> (exemple below)


Use paste(1), sed(1), and a shell with process substitution...

paste data-file <( sed 's/zzzz/yyyy/' data-file )


Janis

>
> Thanks for your ...
>
> before:
> aaaazzzzaaaa
> bbbbzzzzbbbb
> cccczzzzcccc
> ddddzzzzdddd
>
>
> after:
> aaaazzzzaaaa aaaayyyyaaaa
> bbbbzzzzbbbb bbbbyyyybbbb
> cccczzzzcccc ccccyyyycccc
> ddddzzzzdddd ddddyyyydddd
>
>
>

  Réponse avec citation
Vieux 12/11/2007, 23h23   #3
Janis Papanagnou
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: for shell

Janis Papanagnou wrote:
> astalavista wrote:
>
>> hi,
>>
>> I need some for shell.
>> How can modify a file to get
>> the same lines appended
>> the same line with some pattern modified
>> (exemple below)

>
>
> Use paste(1), sed(1), and a shell with process substitution...
>
> paste data-file <( sed 's/zzzz/yyyy/' data-file )


Or use awk...

awk '{x=$0; sub(/zzzz/,"yyyy"); print x,$0}' data-file

(Use printf() or a change the output field separator OFS for other
output formats.)

Janis

>>
>> Thanks for your ...
>>
>> before:
>> aaaazzzzaaaa
>> bbbbzzzzbbbb
>> cccczzzzcccc
>> ddddzzzzdddd
>>
>>
>> after:
>> aaaazzzzaaaa aaaayyyyaaaa
>> bbbbzzzzbbbb bbbbyyyybbbb
>> cccczzzzcccc ccccyyyycccc
>> ddddzzzzdddd ddddyyyydddd
>>
>>
>>

  Réponse avec citation
Vieux 13/11/2007, 20h33   #4
astalavista
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: for shell

OK thanks ..

"Janis Papanagnou" <Janis_Papanagnou@hotmail.com> a écrit dans le message de
news: fhan9n$ktq$1@online.de...
> Janis Papanagnou wrote:
>> astalavista wrote:
>>
>>> hi,
>>>
>>> I need some for shell.
>>> How can modify a file to get
>>> the same lines appended
>>> the same line with some pattern modified
>>> (exemple below)

>>
>>
>> Use paste(1), sed(1), and a shell with process substitution...
>>
>> paste data-file <( sed 's/zzzz/yyyy/' data-file )

>
> Or use awk...
>
> awk '{x=$0; sub(/zzzz/,"yyyy"); print x,$0}' data-file
>
> (Use printf() or a change the output field separator OFS for other
> output formats.)
>
> Janis
>
>>>
>>> Thanks for your ...
>>>
>>> before:
>>> aaaazzzzaaaa
>>> bbbbzzzzbbbb
>>> cccczzzzcccc
>>> ddddzzzzdddd
>>>
>>>
>>> after:
>>> aaaazzzzaaaa aaaayyyyaaaa
>>> bbbbzzzzbbbb bbbbyyyybbbb
>>> cccczzzzcccc ccccyyyycccc
>>> ddddzzzzdddd ddddyyyydddd
>>>
>>>
>>>



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 13h38.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12899 seconds with 12 queries