|
|
|
|
||||||
| comp.unix.shell Using and programming the Unix shell. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 (permalink) |
|
Messages: n/a
Hébergeur: |
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[@]} ************************************************** ********************** |
|
|
|
#2 (permalink) |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#3 (permalink) |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#4 (permalink) |
|
Messages: n/a
Hébergeur: |
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... |
|
|
|
#5 (permalink) |
|
Messages: n/a
Hébergeur: |
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 |
|
![]() |
| Outils de la discussion | |
|
|