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.
What is to be pulled out is the path and file from each line, and erase the rest. (1st line example "/usr/lib/x86_64-linux-gnu/libQtGui.so.4")
I'm guessing a proper way to do this would use the "=> " as the first search point and the " (0" as the end. However I'm not sure how to extract this, nor what option would be best in sed. The main problem for me is I'm not sure if the => are special chars that need a "\" or what to do because the things that are searched for contain "/".
Does anyone have any tips or suggestions for how to approach this? I'd really apprecheate any response.
There are lots of ways to kill this bird. The easiest is probably awk.
Code:
ldd cheezewiz | awk '/=>/{print $3}'
But if you really want to use sed, here are a couple of versions that should work too]
Code:
ldd cheezewiz | sed -rn '/=>/ s/.*=> ([^ ]+) .*/\1/p'
ldd cheezewiz | sed -rn '/=>/ s/(^.*=> | [(].*$)//gp'
By the way, sed's substitution delimiter can be any ascii character, not just '/'. It will use whatever comes directly after the 's', so just use something that doesn't appear in the expression itself. And no, '=' and '>' are not regex special.
Actually, I'd say the second sed command I posted is probably the most reliable. It simply removes everything before and after the desired string, matching them with clearly defined regexes. And all in a single process.
If it's a bit difficult to comprehend, it can also be written this way, with two separate substitutions:
Code:
ldd cheezewiz | sed -n '/=>/ { s/^.*=> // ; s/ [(].*$// ; p }'
Thank you David the H. and H_TeXMeX_H, both work great. As for the links, it seems everytime I need to use sed for something like this it ends up getting figured out, however the very next time I need to use it again, little or nothing from the past can help with a new problem.
I'm checking out the sourceforge grabbag now. Best regards and thanks again for your help!
Yeah, it does take time and effort to gain experience with the tools you use. I know that I had some hair-pulling times myself (still do, occasionally). Just keep plugging away, and it'll eventually get easier.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.