ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
the only difference is that you must not escape the parentheses and the matched text is evaluated as \\1 in the replacement. Note that this function is available only in GNU awk: if compatibility to other awk implementations is an issue, you cannot use gensub.
Thanks for share that and for your explanation, I didn´t know about gensub, and now I understand better why the same regexp wasn´t working in awk for me. It works nice in my cygwin.
Running your script, but replace the pattern with nothing (""), remains a "/" at the end of 3rd column, I now how to delete it with sed using "sed 's/\/$//'". But only if is applied to last column, otherwise the rest of columns are deleted. In order to do not affect other columns information, is better do it with awk I think.
What code is needed to add to your script to delete the remaining "/" when I replace the pattern with "" nothing?
Thanks, thanks colucix. Works great. Something more I´ve learned today!
One more question, maybe somebody knows.
What kind of regexp are used in command shell, for instance, used by awk or sed? Is Perl style or another variant?
I ask this because the regexp used in this problem certainly works with sed and with a little modfication in awk too, but when I test the regexp in a freeware utility like RegExr to test regexp expressions, this regexp doesn´t work.
Regular-expression libraries do (unfortunately...) vary somewhat, although most of them have followed Perl's lead.
Speaking of Perl... It certainly seems to me that Perl might be "the cat's meow" in this situation. It might well be "the right tool for the job."
In the Unix|Linux environments, you have "an embarrassment of riches" with regard to the choice of tools that you have at your disposal (all of them "for free"). It is therefore particularly important to choose what is the appropriate one. For you. For this task. (And as the Perl folks love to say: "TMTOWTDI = There's More Than One Way To Do It.")
I personally think, for example, that lots of folks do amazing things with "shell scripts," even though "shell scripting" was never really designed to do the things that they are managing to do with it. So... are they right or are they not? (You decide.)
Anyhow... always be mindful that you might inadvertantly be using a wrench to drive a nail. Also, always be very mindful that, no matter what you are setting out to do, you are not the first person to have done so. "The time that you unnecessarily wasted with a computer could have been time that you spent drinking a nice celebratory beer."