- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Scripting Question
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2003 08:53 PM
05-29-2003 08:53 PM
Scripting Question
the names in the list are written in the following format.
joe bloggs
harry potter
incredible hulk
space cow
but there are like 200 of them...
Thanks in advance,
Andrew
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2003 09:36 PM
05-29-2003 09:36 PM
Re: Scripting Question
grep -if - /etc/passwd < namelist.txt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2003 09:54 PM
05-29-2003 09:54 PM
Re: Scripting Question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2003 01:58 AM
05-30-2003 01:58 AM
Re: Scripting Question
Try this :-
cat /etc/passwd | sed 's/:/ /' | awk '{print $1}' | sed 's/^/ /' | sed 's/ /last /' >/tmp/name check
then diff the /tmp/namecheck against your name list.
You also might find this useful :-
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x37857d4cf554d611abdb0090277a778c,00.html
HTH
Paula
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2003 02:00 AM
05-30-2003 02:00 AM
Re: Scripting Question
you could try something like this:
#!/usr/bin/sh
while read firstname lastname
do
grep -iE "${firstname}[[:space:]]*${lastname}" /etc/passwd
done <$1
run it like this:
# myscript.sh namefile
handles multiple spaces between first and second names in /etc/passwd. Names in namefile consisting of other than two names will also be processed, however literally.
If the content of your namefile causes an entry to be output more than once, then execute like this:
# myscript.sh namefile | sort -u
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2003 08:45 AM
05-30-2003 08:45 AM
Re: Scripting Question
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2003 08:49 AM
05-30-2003 08:49 AM
Re: Scripting Question
for NAME in `cat $MYFILE`
do
grep $NAME /etc/passwd
if test "$?" -eq "0"
then
echo $NAME>>FOUNDFILE
else
echo $NAME>>NOTFOUNDFILE
fi
done
This would give you two files, one with the names of the users that were in the password table, and another with the names that weren't.
Chris
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2003 08:55 AM
05-30-2003 08:55 AM
Re: Scripting Question
Try this:
for NAME in `cat filewnames`
do
grep -x $NAME /etc/passwd >> output.txt
done
Make sure you create the output.txt file before executing the for i statement.
Regards,
DR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2003 09:08 AM
05-30-2003 09:08 AM
Re: Scripting Question
Have a look at the join command (man join) , it matches fields from two files .
The files must be sorted on the matching field (you have to create a temporary file for the sorted password file).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-30-2003 09:25 AM
05-30-2003 09:25 AM
Re: Scripting Question
Simple example of the join command:
sort -t : -k 5 /etc/passwd >tmp1
sort list >tmp2
join -t : -j1 1 -j2 5 -o 1.1 tmp2 tmp1
Prints out the name from list for each matching line in passwd.