Connecting Tech Pros Worldwide Forums | Help | Site Map

code differences

kaarthikeyapreyan's Avatar
Member
 
Join Date: Apr 2007
Location: India
Posts: 101
#1: 4 Weeks Ago
I am interested to know why the ip are not listed with the -w option in grep
It works fine on my ubuntu 8.04 version(bash) but not in my HP-UX Release 11i (ksh)

Expand|Select|Wrap|Line Numbers
  1. mysys:/tmp/x->find . -type f -print | xargs grep -n -w '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'
  2. mysys:/tmp/x->find . -type f -print | xargs grep -n '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}'
  3. ./test/myfile.txt:2:this line contains ip 192.162.110.2
  4. ./test/myfile.txt:3:mutliple ip on single line 193.254.110.23 ans with the 10.10.10.1
  5. ./test/testfile2.txt:2:192.23.345.45
  6. ./test/testfile2.txt:3:includes ip configured to match teh currenmt 10.11.101.23

micmast's Avatar
Familiar Sight
 
Join Date: Mar 2008
Location: Belgium
Posts: 137
#2: 4 Weeks Ago

re: code differences


what version of grub is on both machines?
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,136
#3: 4 Weeks Ago

re: code differences


do you mean grep? just wondering ... :) .... to get the version of grep you might use:

Expand|Select|Wrap|Line Numbers
  1. grep -V
gives you something like:

Expand|Select|Wrap|Line Numbers
  1. GNU grep 2.5.4
  2.  
  3. Copyright (C) 2009 Free Software Foundation, Inc.
  4. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
  5. This is free software: you are free to change and redistribute it.
  6. There is NO WARRANTY, to the extent permitted by law.
  7.  
kind regards
kaarthikeyapreyan's Avatar
Member
 
Join Date: Apr 2007
Location: India
Posts: 101
#4: 4 Weeks Ago

re: code differences


There was no version information attached to the grep.
but the STANDARDS CONFORMANCE
grep: SVID2, SVID3, XPG2, XPG3, XPG4, POSIX.2

Expand|Select|Wrap|Line Numbers
  1. hp:/preyan->grep -V
  2. grep: illegal option -- V
  3. usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] -e pattern_list...
  4.         [-f pattern_file...] [file...]
  5. usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] [-e pattern_list...]
  6.         -f pattern_file... [file...]
  7. usage: grep [-E|-F] [-c|-l|-q] [-bhinsvx] pattern [file...]
the grep command works as desired in my linux box with the bash shell
but i am interested to know why this is not the same in the HP-UX Release 11i
though it is complaint ot the standard.
kaarthikeyapreyan's Avatar
Member
 
Join Date: Apr 2007
Location: India
Posts: 101
#5: 4 Weeks Ago

re: code differences


Quote:

Originally Posted by micmast View Post

what version of grub is on both machines?

Just got curious on this reply, how does grub play a role in this issue ?
or was that a typo
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,136
#6: 4 Weeks Ago

re: code differences


perhaps:

Expand|Select|Wrap|Line Numbers
  1. grep --version
works to get the verision info? i suspect the -w option could be the problem - just a guess based on the last output you posted?

kind regards
micmast's Avatar
Familiar Sight
 
Join Date: Mar 2008
Location: Belgium
Posts: 137
#7: 4 Weeks Ago

re: code differences


Quote:

Originally Posted by kaarthikeyapreyan View Post

Just got curious on this reply, how does grub play a role in this issue ?
or was that a typo

it doesn't, it should be grep :)
my typing is worse then your average joe, sorry for that :)
kaarthikeyapreyan's Avatar
Member
 
Join Date: Apr 2007
Location: India
Posts: 101
#8: 4 Weeks Ago

re: code differences


Quote:

Originally Posted by gits View Post

perhaps:

Expand|Select|Wrap|Line Numbers
  1. grep --version
works to get the verision info? i suspect the -w option could be the problem - just a guess based on the last output you posted?

kind regards

Yes it is the problem and --version is also an illegal option
-w does not work as expected in this grep.
this does not integrate any version information.
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,136
#9: 4 Weeks Ago

re: code differences


ok ... since it just seems to be clear that it works differently on both of the machines i would suggest to just avoid the -w option and use a regExp instead ... or have a look here at a similar question at the HP resource center

kind regards
Reply