"Transform Text Like a Pro with sed"

  Рет қаралды 1,312

Jake@Linux

Jake@Linux

Күн бұрын

Пікірлер
@binku09
@binku09 6 ай бұрын
HAHAHA THAT THUMBNAIL IS GOLD
@damnhatesyou
@damnhatesyou 6 ай бұрын
Why?
@彩虹97
@彩虹97 6 ай бұрын
yeah, trans text like a pro, literally....
@donaldmickunas8552
@donaldmickunas8552 6 ай бұрын
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. 😉
@dzanful
@dzanful 6 ай бұрын
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_mousse
@anon_y_mousse 6 ай бұрын
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?
@sadmold
@sadmold 6 ай бұрын
Very useful and clear information. Thank you!
@replikvltyoutube3727
@replikvltyoutube3727 6 ай бұрын
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 @
@donaldmickunas8552
@donaldmickunas8552 6 ай бұрын
Indeed, by using another symbol rather than the "/" after the "s" will change the delimiter to that symbol.
@donaldmickunas8552
@donaldmickunas8552 6 ай бұрын
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_mousse
@anon_y_mousse 6 ай бұрын
I often use a comma because it's easy to type and not generally in any strings I process in that way.
@rato_gordo
@rato_gordo 6 ай бұрын
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 ;)
@JakeLinux
@JakeLinux 6 ай бұрын
@@rato_gordo if they are all the same you can run the following: sed -i 's/
@rato_gordo
@rato_gordo 6 ай бұрын
@@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!
@JakeLinux
@JakeLinux 6 ай бұрын
@@rato_gordo thanks I appreciate that
@scottb4029
@scottb4029 6 ай бұрын
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.
@edbeckerich3737
@edbeckerich3737 6 ай бұрын
But I have sed NOTHING...and still got a response, silly software
3 ways to use the Set command to improve your Bash scripts
9:57
Jake@Linux
Рет қаралды 1,6 М.
Building a terminal file manager in Bash
25:57
Jake@Linux
Рет қаралды 6 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
Redcore Linux Proves Gentoo Doesn't Have To Be Difficult
19:18
DistroTube
Рет қаралды 28 М.
WHY did this C++ code FAIL?
38:10
The Cherno
Рет қаралды 298 М.
Flashing MSI Z690 A DDR5 with Dasharo firmware
6:22
3 Awk examples to boost your Linux command line skills
11:48
Jake@Linux
Рет қаралды 3,5 М.
it's been a rough week for microsoft...
10:22
Low Level
Рет қаралды 286 М.
NEVER install these programs on your PC... EVER!!!
19:26
JayzTwoCents
Рет қаралды 4,5 МЛН
How to configure or customize Bash: My first steps for my setup
33:26
Building a Void-src template for Brave
24:51
Jake@Linux
Рет қаралды 1,8 М.
My Brain after 569 Leetcode Problems
7:50
NeetCode
Рет қаралды 2,7 МЛН
Plasma 6.1: the BEST LINUX DESKTOP (in my opinion)
17:03
The Linux Experiment
Рет қаралды 170 М.
When you have a very capricious child 😂😘👍
00:16
Like Asiya
Рет қаралды 18 МЛН