Jake, The real power, in that third example, was in all of that middle part in the sed command. Those are regular expressions which is a language all it's own. Awk. Sed, and Regular Expressions, when used together effectively, can manipulate large amounts of text quickly. Most computer users today have never heard of these tools mainly because they require some work to learn how to use. Most people aren't willing to put in the work. I think that is a bad decision. I started diving into Regular Expressions about a year ago, using the classic book "Mastering Regular Expressions by Jeffery Friedl", but health issues put a stop to that endeavor. It is time to jump back in. 😉
@dzanful6 ай бұрын
Your statement that the `-E' flag enables extended regular expressions is true, but can be easily misunderstood. Actually, the only difference between regular and extended regular expressions is that in the latter, special characters like '?', '+' and '()' aren't escaped with a backslash '\' character, otherwise they become literal. So the main purpose of ERE is to make regular expressions more readable and less prone to human error. Consider the following two sed commands, with and without the `-E' flag, both producing the same output: $ echo a b | sed -E 's/(\S+)\s(\S+)/\2 \1/' b a $ echo a b | sed 's/\(\S\+\)\s\(\S\+\)/\2 \1/' b a However, basic regular expressions may be more convenient in some cases: $ echo '(a) (b)' | sed 's/(\w)/(x)/g' (x) (x) $ echo '(a) (b)' | sed -E 's/\(\w\)/(x)/g' (x) (x) Understanding this small difference between BRE and ERE can save a lot of time and confusion when working with sed and grep. But there's so much more sed can do, including flow control, which is rarely if ever mentioned by most content authors on the web.
@anon_y_mousse6 ай бұрын
Only recommendations I have is to do a whole word search when replacing simple strings like 'cat'. For instance, if you have a file listing 'Categories of Cats' and you don't do whole word, you'll get 'Dogegories of Dogs'. For whole word, enclose in alligator clips which I can't demonstrate without my post being deleted (not your fault, just KZbin hates me). Also, if you are deleting based on a potentially mixed case string, if you're using GNU `sed`, then you can use 'Id' instead of just 'd'. Note that's capital eye before the dee. I'm told it's not portable, but who actually uses a different version of `sed` if you're on Linux?
@sadmold6 ай бұрын
Very useful and clear information. Thank you!
@replikvltyoutube37276 ай бұрын
Slashes Can be actually any symbol IIRC. Since slashes can make problems with escaping and usage in bash scripts, it's better to use some not interpreted symbol like ! or @
@donaldmickunas85526 ай бұрын
Indeed, by using another symbol rather than the "/" after the "s" will change the delimiter to that symbol.
@donaldmickunas85526 ай бұрын
Jake, You should do more short videos like this one. No one is teaching this stuff any more. Regular Expressions can be used in many Linux commands. Knowing them can allow the user to accomplish much in a few lines of code. Powerful, heady stuff when applied.
@anon_y_mousse6 ай бұрын
I often use a comma because it's easy to type and not generally in any strings I process in that way.
@rato_gordo6 ай бұрын
I'm trying to solve a need while being a noob. I have 37 html files where I want to change the code, e.g. I forgot a alt tag for an image. With sed it is possible to do it in all files at once? I'll definetely read sed man asap ;)
@JakeLinux6 ай бұрын
@@rato_gordo if they are all the same you can run the following: sed -i 's/
@rato_gordo6 ай бұрын
@@JakeLinux thx for the help! I'll look into It and make tests, before losing stuff, lol. As another folk commented here... time to start learning regex. Your videos are really good Jake!
@JakeLinux6 ай бұрын
@@rato_gordo thanks I appreciate that
@scottb40296 ай бұрын
Sed and AWK are cool, but not as cool as set. Loved the video. I am worried about you, what is going on with your throat? Btw tea with honey coats the vocal cords.
@edbeckerich37376 ай бұрын
But I have sed NOTHING...and still got a response, silly software