Help for shell
am 12.11.2007 21:49:19 von Patrice
hi,
I need some help 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 help ...
before:
aaaazzzzaaaa
bbbbzzzzbbbb
cccczzzzcccc
ddddzzzzdddd
after:
aaaazzzzaaaa aaaayyyyaaaa
bbbbzzzzbbbb bbbbyyyybbbb
cccczzzzcccc ccccyyyycccc
ddddzzzzdddd ddddyyyydddd
Re: Help for shell
am 13.11.2007 00:19:14 von Janis Papanagnou
astalavista wrote:
> hi,
>
> I need some help 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 help ...
>
> before:
> aaaazzzzaaaa
> bbbbzzzzbbbb
> cccczzzzcccc
> ddddzzzzdddd
>
>
> after:
> aaaazzzzaaaa aaaayyyyaaaa
> bbbbzzzzbbbb bbbbyyyybbbb
> cccczzzzcccc ccccyyyycccc
> ddddzzzzdddd ddddyyyydddd
>
>
>
Re: Help for shell
am 13.11.2007 00:23:34 von Janis Papanagnou
Janis Papanagnou wrote:
> astalavista wrote:
>
>> hi,
>>
>> I need some help 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 help ...
>>
>> before:
>> aaaazzzzaaaa
>> bbbbzzzzbbbb
>> cccczzzzcccc
>> ddddzzzzdddd
>>
>>
>> after:
>> aaaazzzzaaaa aaaayyyyaaaa
>> bbbbzzzzbbbb bbbbyyyybbbb
>> cccczzzzcccc ccccyyyycccc
>> ddddzzzzdddd ddddyyyydddd
>>
>>
>>
Re: Help for shell
am 13.11.2007 21:33:00 von Patrice
OK thanks ..
"Janis Papanagnou" a écrit dans le message de
news: fhan9n$ktq$1@online.de...
> Janis Papanagnou wrote:
>> astalavista wrote:
>>
>>> hi,
>>>
>>> I need some help 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 help ...
>>>
>>> before:
>>> aaaazzzzaaaa
>>> bbbbzzzzbbbb
>>> cccczzzzcccc
>>> ddddzzzzdddd
>>>
>>>
>>> after:
>>> aaaazzzzaaaa aaaayyyyaaaa
>>> bbbbzzzzbbbb bbbbyyyybbbb
>>> cccczzzzcccc ccccyyyycccc
>>> ddddzzzzdddd ddddyyyydddd
>>>
>>>
>>>