[opensuse] Add variables to standard output for



Ok, I don't know how to word my question properly. I am writing a
script that greps for a string (for a command that has multiple lines of
output - the finger command)


My problem: I want to take the standard output (1) from a grep
command, but I also want to add my own values to the resulting line.
Let's use a simple example:

My script:
-----------
for i in `sort /etc/passwd | cut -f1 -d":"`
do
finger $i | grep -i last
done


The output will look like this:
--------------------------------
Last login Fri Jan 18 09:32 (SAST) on 57 from 163.197.212.133
Last login Fri Aug 31 13:06 (SAST) on 38 from 163.197.212.113
Last login Mon Jan 14 11:23 (SAST) on 39 from 163.197.208.90
Last login Wed Sep 12 08:00 (SAST) on 153 from 163.197.212.142
Last login Fri Jul 6 09:13 2007 (SAST) on 188 from 163.197.222.37
Last login Wed Feb 21 08:21 2007 (SAST) on 155 from 163.197.206.103
Last login Fri Jan 18 11:01 (SAST) on 218 from 163.197.212.11
Last login Thu Dec 20 10:50 (SAST) on 196 from 163.197.210.31
Last login Fri May 4 11:47 2007 (SAST) on 88 from 163.197.207.16
Last login Fri Jan 18 09:15 (SAST) on 81 from 163.197.212.83



BUT, I want to add the user's login to the lines above, for example:

$i: Last login Fri Jan 18 09:32 (SAST) on 57 from 163.197.212.133
$i: Last login Fri Aug 31 13:06 (SAST) on 38 from 163.197.212.113
$i: Last login Mon Jan 14 11:23 (SAST) on 39 from 163.197.208.90
$i: Last login Wed Sep 12 08:00 (SAST) on 153 from 163.197.212.142
$i: Last login Fri Jul 6 09:13 2007 (SAST) on 188 from 163.197.222.37

where $i is the login of the user from the script


How can I place $i, and the standard output of grep, on the same line
(make it 1 line of output) ?



Dirk


*** Disclaimer ***

The information contained in this e-mail is confidential and legally privileged and is intended solely for the addressee and to others who have the authority to receive it. Access to this e-mail by anyone else is unauthorized and as such, any disclosure, copying, distribution or any action taken or omitted in reliance on it is unlawful. If you have received this e-mail in error, please notify the sender immediately.

The views expressed in this e-mail are the views of the individual sender and should in no way be construed as the views of the Company.

The Company is not liable to ensure that outgoing e-mails are virus-free.

The Company is not liable, should information or data, for whatever reason, be corrupted or fail to reach its intended addressee.

The Company is not liable for any loss or damage of whatsoever nature and howsoever arising resulting from the opening or the use of the information in this e-mail, including its attachments and links.

The sender of this e-mail is subject to and bound by the terms and conditions of Company+IBk-s Electronic Communications Usage Policy.
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx



Relevant Pages

  • Re: new guy ksh scripting questions
    ... script to be called from the crontab of the Oracle user. ... command into a grep command looking for ALIVE, pipe that into a wc -l ... then echo good ...
    (comp.unix.aix)
  • Re: [opensuse] Add variables to standard output for
    ... output - the finger command) ... I want to take the standard output from a grep ... My script: ...
    (SuSE)
  • Re: want to ask how to use grep -v repeatly
    ... i am a new user for unix, and is writing a script for working purpose. ... could someone tell how can I "grep -v " more than a string in ... a command, cause the machine i'm using is very busy. ... when I pipe the ...
    (comp.unix.shell)
  • Re: bash: any way to reuse the last output?
    ... > manipulate the last output gets me by surprise, I will do, for instance: ... > (say, with grep) ... you can use script command. ...
    (Fedora)
  • [opensuse] error Output
    ... I have a script that counts the number of files in a certain directory. ... The command I use is: ... What should my syntax be for this line? ... The views expressed in this e-mail are the views of the individual sender and should in no way be construed as the views of the Company. ...
    (SuSE)