/dev/null is to keep grep quiet... otherwise it would output the line that
matched. If you want to see it when a match is found, then you could take
that out. The break is there so when it finds a match it breaks out of the
loop, since there's no reason to keep looping once a match is found.
If you want to pipe the output of scs2ascii through this script, you would
have to do it like so:
#! /bin/bash
file=`cat /dev/stdin`
users="PHILLIP SAM RICHARD"
for user in $users; do
echo "$file" | grep $user >/dev/null && echo "$file" >
/home/misadmin/"$user"_`date
+%Y-%m-%d-%H:%m` && break
done
--- - Toby Stanfill
--- - Sr. Programmer/Analyst
--- - O'Reilly Auto Parts
--- - (417)862-2674 ext. 1291
This message is protected by the Electronic Communications Privacy Act, 18
USCS § 2510 et seq., and may not be used, copied or forwarded without the
consent of the named recipient(s). The information contained in this
message is confidential, is intended only for the use of the individual or
entity named. If the reader of this message is not the intended recipient,
you are hereby notified that any dissemination, distribution or copying of
this communication is strictly prohibited. If you have received this
communication in error, please notify me immediately at 417-862-2674 ext
1291.
"Mitch Martin"
<mmartin@monroenc
.org> To
Sent by: "Linux 5250 Development Project"
linux5250-bounces <linux5250@xxxxxxxxxxxx>
@midrange.com cc
Subject
08/08/2008 12:46 Re: [LINUX5250] Script file to
PM customize scs2ascii output
-Assistance needed.
Please respond to
Linux 5250
Development
Project
<linux5250@midran
ge.com>
Toby,
That certainly worked for me. Would you explain the reason for
/dev/null and the break command? In the mean time, I will research it
in my book.
Also, will this script work by piping the output of scs2ascii to my
script? I haven't tried that yet. Here is the script, so far:
#! /bin/bash
file=/home/misadmin/ID-4892.txt
users="PHILLIP SAM RICHARD"
for user in $users; do
grep $user $file >/dev/null && cat $file > /home/misadmin/"$user"_`date
+%Y-%m-%d-%H:%m` && break
done
Something like this should work...
users="user1 user2 user3 user4 user5"
file=<name of file>
for user in $users; do
grep $user $file >/dev/null && cat $file > /tmp/"$user"_`date
+%Y-%m-%d-%H:%m` && break
done
--- - Toby Stanfill
--- - Sr. Programmer/Analyst
--- - O'Reilly Auto Parts
--- - (417)862-2674 ext. 1291
--
This is the Linux 5250 Development Project (LINUX5250) mailing list
To post a message email: LINUX5250@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/linux5250
or email: LINUX5250-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
http://archive.midrange.com/linux5250.
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean (mailgw2:0B2511F56A0.44E67).
As an Amazon Associate we earn from qualifying purchases.