[SOLVED] Issue trying to grep a string, but keep a similar string
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
Last edited by Supp0rtLinux; 10-03-2011 at 02:00 PM.
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?
FYI: I'm on Solaris 10... not sure if this is relevant.
No, the problem in this case is not w/ slowarse as I lovingly
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
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):
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.