RE: [opensuse] Add variables to standard output for



Great - thank you very much :-)

I had to change the syntax a little, but it works :-)


for i in `sort /etc/passwd | cut -f1 -d":"`
do
if blubb=`finger $i | grep Last`
then
echo "$i: $blubb"
fi
done


Dirk

-----Original Message-----
From: Henne Vogelsang [mailto:hvogel@xxxxxxxxxxxx]
Sent: 18 January 2008 04:34 PM
To: opensuse@xxxxxxxxxxxx
Subject: Re: [opensuse] Add variables to standard output for

Hi,

On Friday, January 18, 2008 at 11:52:35, Dirk Moolman wrote:

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 Mon Jan 14 11:23 (SAST) on 39 from 163.197.208.90

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

for i in `sort /etc/passwd | cut -f1 -d":"`
do
if blubb=`finger $i | grep Last`; then
echo "$i: $blubb";
fi
done

Henne

--
Henne Vogelsang, openSUSE.
Everybody has a plan, until they get hit.
- Mike Tyson
--
To unsubscribe, e-mail: opensuse+-unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+-help@xxxxxxxxxxxx



*** 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: MacTeX 2007 and documentation
    ... may be the most useful command available when doing searches at the ... will find every file on your system that has the text "memoir" on it, ... If locate generates 30 lines of text, where each line is a file, grep ... I need a Unix guru to chat to for half an hour or so to put me straight. ...
    (comp.text.tex)
  • [opensuse] Add variables to standard output for
    ... output - the finger command) ... I want to take the standard output from a grep ... My script: ... 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)
  • Re: piping multiple selections to mv or cp and exclusion
    ... pipe to shell to execute each command statement ... Unix is indeed lifelong learning :-) ... and the regexp. ... back into the grep statement. ...
    (comp.unix.shell)
  • Re: MacTeX 2007 and documentation
    ... means you need expertise in your host operating system as well. ... locate memoir | grep pdf ... I'm not someone who lives at the command line, ...
    (comp.text.tex)
  • Re: Program to scan directories
    ... Is there a UNIX command which scans directories and execute any other ... the regex you specify here is /not/ given to grep to ... entries (files and subdirectories). ... tell grep to recurse through the kpathsea directory (the *.h regex ...
    (comp.unix.programmer)

Loading