ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
Well for starters, you can use the -r option so you don't have to escape the special characters like you're doing above. That'll cut out I don't know how many backslashes.
Second, for the times where you're looking for consonants you can do [^aeiou] which is shorter than [bcdfghjklmnpqrstvxwz].
For the times where you're specifying [d][d][d] for example you can just use d{3}.
I'm not sure why you're using \1 in certain places when that's usually a back-ref but I'm not extraordinarily familiar with sed.
Please use [code][/code] tags around your code, to preserve formatting and to improve readability.
And whatever else, a command that long and complex really should be placed into its own script file, complete with clear formatting (one expression per line) and comments, so that it's more easily readable and comprehensible.
Then use sed -f scriptfile to run it.
Finally, how about an example of the input text, so we can see what it's supposed to do, and to test variations?
Edit:
Quote:
Originally Posted by Ian John Locke II
I'm not sure why you're using \1 in certain places when that's usually a back-ref but I'm not extraordinarily familiar with sed.
Yes, those are back-references. They aren't just for the replacement field. It's possible to reuse them inside the original expression too.
So if I'm reading it right, the first expression should match any repeating sequence of two digits (87, 8787, 878787, etc).
But since the repeat has been told to match the repeat zero or more times ( {0,} == * ), and the command is simply to delete the line, it seems to me that all that extra is superfluous. Simply matching the first two digits alone will achieve the same effect.
Code:
-e '/[0-9]{2}/d'
***Edit2: I just realized this is the same guy who was warned recently about posting some kind of cracking question. I think we really need to hear more about the purpose of this code before helping him further.
Last edited by David the H.; 11-08-2011 at 10:39 AM.
Reason: as stated
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.