|
I understand that we're supposed to keep language specific questions in their related threads, but I don't see any current threads on shell scripting or sed. If I'm wrong, feel free to ridicule me. With that out of the way, my question is about using regular expressions with sed. I'm searching a line of numbers and symbols and only want a certain group of numbers. My input string will look like this: code:
I've tried the following (and many variations) with no luck. This regex makes the most sense to me in this context: code:
|
# ¿ Feb 28, 2008 19:06 |
|
|
# ¿ May 7, 2024 03:53 |
|
bitprophet posted:Must be sed's interpretation of regex, I wasn't able to convince it to do what you want (not even anything as simple as '[0-9]+' was matching, so either I was being retarded in my sed usage or that's the aspect it doesn't support...?) but Python's RE library works fine, I think it's largely PCRE compatible: It doesn't look like my version of sed (4.0.7) supports -E, which seems odd. Maybe it's a GNU thing? Either way, your post (and a cup of tea) showed me exactly what I was missing, and it's totally embarrassing. I was forgetting to give sed a search command! I'm so ashamed of myself right now. With a little fiddling I was able to get your version to work and my problem is solved. Thank you very much!
|
# ¿ Feb 28, 2008 20:21 |
|
axolotl farmer posted:Here's my very ugly take on it! That's a cool method as well (took me a second to spot the space), and it's not nearly as ugly as the entire command I'm using to get my string. Thanks to everyone for the replies.
|
# ¿ Feb 28, 2008 20:37 |
|
Plastic Jesus posted:It might be simpler (and possibly faster) to just 'cut' twice instead of sed: That's an excellent point. Using a regex in my situation is overkill. I think I'll just use this method.
|
# ¿ Feb 29, 2008 16:24 |
|
I want to use a unix shell script to generate a plain text file of sequential ten digit numbers (from 0000000000 to 9999999999) with each separated by a carriage return. Something like this: 0000000000 0000000001 ... 9999999998 9999999999 What is the most efficient way to do this? EDIT: Thanks for all the helpful answers! furtheraway fucked around with this message at 17:36 on May 28, 2010 |
# ¿ May 28, 2010 16:45 |
|
|
# ¿ May 7, 2024 03:53 |
|
Awesome. Thanks for the tips, everyone. Especially about the write bottleneck, since I hadn't even considered that mess.
|
# ¿ May 28, 2010 17:55 |