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 > Ned to append 2nd line to the first
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Ned to append 2nd line to the first

Réponse
 
LinkBack Outils de la discussion
Vieux 22/08/2006, 13h33   #1 (permalink)
cberthu@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Ned to append 2nd line to the first

Hi all,

Sorry to bother but I am a rookie and got this to do.
I need to format this output :
"************************************************* ***********************"
S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2
audit object read event detected /etc/security/passwd
S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2bp
audit object read event detected /etc/security/passwd
S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2bp
audit object read event detected /etc/security/passwd
S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2bp
audit object read event detected /etc/security/passwd
S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2bp
audit object read event detected /etc/security/passwd

"************************************************* ***********************"

So that the 2nd lined is append to the first till the end of the
output.

I got the input file into a arry and I block somehow now...
************************************************** **********************
if [ "$#" -eq "0" ]
then
echo "==> Please give the full path for the incoming file"
read INPUT
echo "Your answer was" $INPUT
fi
file_name=$INPUT
i=0
while read file_line
do
line_array[i]=${file_line}
echo "This is the line:" $file_line
echo $file_line >> /u/t315511/scripts/chris.out
if [ "^$file_line" = " " ]
then
echo "Here is one " $file_line
fi
let i=${i}+1
done < ${file_name}
echo ${line_array[@]}
************************************************** **********************

  Réponse avec citation
Vieux 22/08/2006, 14h00   #2 (permalink)
Ed Morton
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Ned to append 2nd line to the first

cberthu@gmail.com wrote:
> Hi all,
>
> Sorry to bother but I am a rookie and got this to do.
> I need to format this output :
> "************************************************* ***********************"
> S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2
> audit object read event detected /etc/security/passwd
> S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2bp
> audit object read event detected /etc/security/passwd
> S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2bp
> audit object read event detected /etc/security/passwd
> S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2bp
> audit object read event detected /etc/security/passwd
> S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2bp
> audit object read event detected /etc/security/passwd
>
> "************************************************* ***********************"
>
> So that the 2nd lined is append to the first till the end of the
> output.
>
> I got the input file into a arry and I block somehow now...
> ************************************************** **********************
> if [ "$#" -eq "0" ]
> then
> echo "==> Please give the full path for the incoming file"
> read INPUT
> echo "Your answer was" $INPUT
> fi
> file_name=$INPUT
> i=0
> while read file_line
> do
> line_array[i]=${file_line}
> echo "This is the line:" $file_line
> echo $file_line >> /u/t315511/scripts/chris.out
> if [ "^$file_line" = " " ]
> then
> echo "Here is one " $file_line
> fi
> let i=${i}+1
> done < ${file_name}
> echo ${line_array[@]}
> ************************************************** **********************
>


awk 'NR%2{s=$0;next}{print s$0}' file

Ed.
  Réponse avec citation
Vieux 22/08/2006, 14h23   #3 (permalink)
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Ned to append 2nd line to the first

On 22 Aug 2006 05:33:28 -0700, cberthu@gmail.com
<cberthu@gmail.com> wrote:
> Hi all,
>
> Sorry to bother but I am a rookie and got this to do.
> I need to format this output :
> "************************************************* ***********************"
> S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2
> audit object read event detected /etc/security/passwd
> S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2bp
> audit object read event detected /etc/security/passwd
> S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2bp
> audit object read event detected /etc/security/passwd
> S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2bp
> audit object read event detected /etc/security/passwd
> S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2bp
> audit object read event detected /etc/security/passwd
>
> "************************************************* ***********************"
>
> So that the 2nd lined is append to the first till the end of the
> output.
>

paste - - < file


--
mixed emotions:
Watching a bus-load of lawyers plunge off a cliff.
With five empty seats.
  Réponse avec citation
Vieux 22/08/2006, 18h41   #4 (permalink)
cberthu@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Need to append 2nd line to the first

Ed Morton wrote:
> cberthu@gmail.com wrote:
> > Hi all,
> >
> > Sorry to bother but I am a rookie and got this to do.
> > I need to format this output :
> > "************************************************* ***********************"
> > S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2
> > audit object read event detected /etc/security/passwd
> > S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2bp
> > audit object read event detected /etc/security/passwd
> > S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2bp
> > audit object read event detected /etc/security/passwd
> > S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2bp
> > audit object read event detected /etc/security/passwd
> > S_PASSWD_READ patrol3 OK Sat Aug 19 09:30:03 2006 db2bp
> > audit object read event detected /etc/security/passwd
> >
> > "************************************************* ***********************"
> >
> > So that the 2nd lined is append to the first till the end of the
> > output.
> >
> > I got the input file into a arry and I block somehow now...
> > ************************************************** **********************
> > if [ "$#" -eq "0" ]
> > then
> > echo "==> Please give the full path for the incoming file"
> > read INPUT
> > echo "Your answer was" $INPUT
> > fi
> > file_name=$INPUT
> > i=0
> > while read file_line
> > do
> > line_array[i]=${file_line}
> > echo "This is the line:" $file_line
> > echo $file_line >> /u/t315511/scripts/chris.out
> > if [ "^$file_line" = " " ]
> > then
> > echo "Here is one " $file_line
> > fi
> > let i=${i}+1
> > done < ${file_name}
> > echo ${line_array[@]}
> > ************************************************** **********************
> >

>
> awk 'NR%2{s=$0;next}{print s$0}' file
>
> Ed.



Thanks Ed

Hey it looks so simple and it is actually...... Thanks a lot...

  Réponse avec citation
Vieux 22/08/2006, 19h01   #5 (permalink)
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Need to append 2nd line to the first

2006-08-22, 10:41(-07), cberthu@gmail.com:
[...]
>> awk 'NR%2{s=$0;next}{print s$0}' file
>>
>> Ed.

>
>
> Thanks Ed
>
> Hey it looks so simple and it is actually...... Thanks a lot...


That's a bit overkill compared to

paste -d'\0' - - < file
or
paste -sd'\0\n' file

though and would discard the last line of a file with an odd
number of lines.

--
Stéphane
  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 02h41.


Édité par : vBulletin® version 3.7.2
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
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,12540 seconds with 13 queries