Issue trying to grep a string, but keep a similar string
I have a output string that looks like this:
hp31408804325.ir.cs.domain.edu 21.23 GB ilmn-pipeline.ir.cs.domain.edu 38.73 GB imhotep 0 kb imhotep.ir.cs.domain.edu 164.10 GB ipcam.ir.cs.domain.edu 8477.25 GB ishtar-backups.ir.cs.domain.edu 125204.38 GB I need to grep out (ie: "grep -v ..."or "egrep -v ...") the string "imhotep" above, but retain the longer string "imhotep.ir.cs.domain.edu". Specifically, this relates to our backup software. At one point, a previous admin had setup the hosts by their short name. This was later changed to FQDN names, however our reports are still showing the short name due to some "never expire" archive policies. I want to remove the short name entry as its not relevant to our reports, but keep the long name. This would be trivial if I were doing it the other way around, but I can't figure out how to grep out the short name yet retain the longer name. Any thoughts? |
Quote:
Code:
echo "hp31408804325.ir.cs.domain.edu 21.23 GB first word of a line. Cheers, Tink |
Great suggestion, but it doesn't seem to work:
bash-3.00# echo "imhotep" | egrep -v '^[^.]+ ' imhotep FYI: I'm on Solaris 10... not sure if this is relevant. |
Quote:
call it, neither with its geriatric toolset; it's w/ the regex, or rather the input you're throwing it: it doesn't resemble what you told us you're looking for, there's no trailing whitespace in "imhotep", hence the regex won't take. If you tried Code:
echo "imhotep " | egrep -v '^[^.]+ ' Cheers, Tink |
Thanks for the clarification. I guess my snippet of data didn't properly reflect the environment. In the case of only having hostnames (and no trailing whitespace - see example below):
hp31408804325.ir.cs.domain.edu ilmn-pipeline.ir.cs.domain.edu imhotep imhotep.ir.cs.domain.edu ipcam.ir.cs.domain.edu ishtar-backups.ir.cs.domain.edu How would I grep out the short hostname "imhotep", but keep the FQDN hostname "imhotep.ir.cs.domain.edu"? |
almost the same:
Code:
echo "hp31408804325.ir.cs.domain.edu |
Thanks... that did the trick
|
Welcome. You get the difference between the regexes, and why
which one works with which data set? Cheers, Tink |
All times are GMT -5. The time now is 07:59 AM. |