- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: grep: illegal option----????????
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
08-22-2003 09:10 AM
08-22-2003 09:10 AM
#
print "Login Name\t" "Pri Group\t" "Member of Group"
grep -i "${1}" /etc/passwd > /dev/null
if [ $? -eq 0 ]; then
grep -i "${1}" /etc/passwd | awk 'BEGIN {
print "\n"
FS=":"
OFS="\t" }
{
GROUP=""
PGRP=""
"grep -i "$4" /etc/group | cut -f 1 -d ':'" | getline PGRP;
"echo "$5" | cut -f 1 -d ','" | getline RNAME;
"echo "$5" | cut -f 3 -d ','" | getline RNUM;
"/usr/bin/groups -g " $1 | getline GROUP;
print $1"\t\t" PGRP"\t" "\t" GROUP
print " ";
}'
else
echo "No user details found....Sorry. Try again..."
fi
exit 0;
I can't figure out what's wrong
Need fresh eyes on it can somebody help
runs find with desirable output and sneezes in the middle and than continues
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2003 09:22 AM
08-22-2003 09:22 AM
Re: grep: illegal option----????????
I get the same error. Check your passwd file if there is any fields with "-" in. grep interpret it as an option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2003 09:25 AM
08-22-2003 09:25 AM
Re: grep: illegal option----????????
I got them ..but I need to keep them ...what can I do to ignore them
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2003 09:27 AM
08-22-2003 09:27 AM
Re: grep: illegal option----????????
Check whether /etc/passwd contains entry for nobody with -2 etc.
It is causing the trouble.
HTH,
Umapathy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2003 09:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2003 09:28 AM
08-22-2003 09:28 AM
Re: grep: illegal option----????????
You are feeding this script an argument that contains a "-" and grep is then trying to interpret your ${1} as an option.
Change your grep -i "${1}" to
grep -i -- "${1}"
The -- instructs getopt() that the argument list is ended; anything beyond this is not to be evaluated as an option.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2003 09:31 AM
08-22-2003 09:31 AM
Re: grep: illegal option----????????
"grep -i "$4" /etc/group | cut -f 1 -d ':'" | getline PGRP;
Will get an error if $4 is a negative number (like user nobody) and it thinks you are passing another option.
If you code
grep -i -- "$4" ...
then grep will not try to treat $4 as an option if it begins with a "-"
HTH
-- Rod Hills
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2003 09:32 AM
08-22-2003 09:32 AM
Re: grep: illegal option----????????
A different method:
try
a=-2
grep \\$(echo $a) /etc/passwd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2003 09:37 AM
08-22-2003 09:37 AM
Re: grep: illegal option----????????
Thank you for your help