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

awk -simple doubt

Réponse
 
LinkBack Outils de la discussion
Vieux 15/03/2008, 20h37   #1
varkey@changingideas.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut awk -simple doubt

hey guys,

i hav got two files as follows

file1.txt

bss:1
bss:2
bss:3
bss:4
bss:5


file2.txt
db1
db2
db3
db4
db5


i m reading the first file using a for loop

so when i read the first line in file1.txt (ie bss:1) i need to get
the corresponding one in file2 (ie. db1)

like wise till db5 when i reads bss:5

how can i implemnt it usig an awk with in a for loop?

thanks in advance

  Réponse avec citation
Vieux 15/03/2008, 21h29   #2
pk
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: awk -simple doubt

varkey@changingideas.com wrote:

> hey guys,
>
> i hav got two files as follows
>
> file1.txt
>
> bss:1
> bss:2
> bss:3
> bss:4
> bss:5
>
>
> file2.txt
> db1
> db2
> db3
> db4
> db5
>
>
> i m reading the first file using a for loop


Using something like

for line in `cat file1.txt`

I suppose.

> so when i read the first line in file1.txt (ie bss:1) i need to get
> the corresponding one in file2 (ie. db1)
>
> like wise till db5 when i reads bss:5
>
> how can i implemnt it usig an awk with in a for loop?


You can use awk without any loop at all (assuming your input lines have no
spaces in them):

$ paste file1.txt file2.txt | awk '{print $1,$2}'

or, if you absolutely want to use a loop

$ paste file1.txt file2.txt | while read line1 line2; do
....

--
All the commands are tested with bash and GNU tools, so they may use
nonstandard features. I try to mention when something is nonstandard (if
I'm aware of that), but I may miss something. Corrections are welcome.
  Réponse avec citation
Vieux 16/03/2008, 19h44   #3
Ed Morton
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: awk -simple doubt



On 3/15/2008 2:37 PM, varkey@changingideas.com wrote:
> hey guys,
>
> i hav got two files as follows
>
> file1.txt
>
> bss:1
> bss:2
> bss:3
> bss:4
> bss:5
>
>
> file2.txt
> db1
> db2
> db3
> db4
> db5
>
>
> i m reading the first file using a for loop
>
> so when i read the first line in file1.txt (ie bss:1) i need to get
> the corresponding one in file2 (ie. db1)
>
> like wise till db5 when i reads bss:5
>
> how can i implemnt it usig an awk with in a for loop?
>
> thanks in advance
>


It sounds like all you really want is:

paste file1 file2

If not post a rationale and some expected output for .

Ed.

  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 06h16.


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