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 > File Content Alteration
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

File Content Alteration

Réponse
 
LinkBack Outils de la discussion
Vieux 23/07/2007, 15h05   #1
pankaj_wolfhunter@yahoo.co.in
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut File Content Alteration

Greetings,
I have a file with contents something like

1#data1
data2#
2#data3#
3#data4#

How can I replace the '#' at the end of each line with something like
'||'.
Here the data section might contain some newline characters which I
want to ignore

So the output should be

1#data1
data2||
2#data3||
3#data4||

Any would be appreciated.

TIA

  Réponse avec citation
Vieux 23/07/2007, 15h07   #2
Icarus Sparry
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: File Content Alteration

On Mon, 23 Jul 2007 07:05:21 -0700, pankaj_wolfhunter@yahoo.co.in wrote:

> Greetings,
> I have a file with contents something like
>
> 1#data1
> data2#
> 2#data3#
> 3#data4#
>
> How can I replace the '#' at the end of each line with something like
> '||'.
> Here the data section might contain some newline characters which I want
> to ignore
>
> So the output should be
>
> 1#data1
> data2||
> 2#data3||
> 3#data4||
>
> Any would be appreciated.
>
> TIA


sed 's/#$/||/'

The dollar character matches at the end of line.
  Réponse avec citation
Vieux 23/07/2007, 15h15   #3
pankaj_wolfhunter@yahoo.co.in
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: File Content Alteration

On Jul 23, 7:07 pm, Icarus Sparry <use...@icarus.freeuk.com> wrote:
> On Mon, 23 Jul 2007 07:05:21 -0700, pankaj_wolfhun...@yahoo.co.in wrote:
> > Greetings,
> > I have a file with contents something like

>
> > 1#data1
> > data2#
> > 2#data3#
> > 3#data4#

>
> > How can I replace the '#' at the end of each line with something like
> > '||'.
> > Here the data section might contain some newline characters which I want
> > to ignore

>
> > So the output should be

>
> > 1#data1
> > data2||
> > 2#data3||
> > 3#data4||

>
> > Any would be appreciated.

>
> > TIA

>
> sed 's/#$/||/'
>
> The dollar character matches at the end of line.- Hide quoted text -
>
> - Show quoted text -


Thanks. Actually still on the learning curve so sorry for such
question.
Thanks again.

  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 07h31.


É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,08305 seconds with 11 queries