Using `sed` and Regular Expressions (Unix/Linux command line)

preview_player
Показать описание
Absolutely everything you're looking for is here:
Рекомендации по теме
Комментарии
Автор

This command would still print blank lines with spaces so use '^\s*$' for maximum autism

annexedolphin
Автор

Luke: "You're not autistic, you're normal"
Also Luke: Makes torrent status bar module that utilizes sed when you could just open your torrent client instead.

mkd
Автор

The name comes from the program ed, as in editor. Ed uses special regex for editing. Sed is the same as ed but it ONLY uses regex for editing. Vi, the text editor, is built ON TOP of ed so you can use all the commands from sed in vi. Vim is BASED ON the idea of vi and all the commands work there too.
Then there's acme/sam and vis. Regex is a big part of acme and sam because you have to use the mouse otherwise. It uses special regex called plan9 regex. Vis is basically a cut down version of vim that uses the plan9 regex (which is superior). I recommend trying to write scripts in ed instead of using awk, if you learn the sed syntax!

auslegungssache
Автор

"sed 11q" actually prints the 11th line. To quit before the 11th line gets printed you would need to use GNU extension 'Q' ( "sed 11Q" ), or actually use "sed 10q". ( try "seq 20 | sed 10q" vs "seq 20 | sed 11Q" ).

michalvlasak
Автор

You might not have to download 500mb of python modules to make a torrent statusbar thing but you do need to download 500mb of fonts to find one with the emojis in it

tristanbellingham
Автор

This is very helpful, I appreciate this sort of content. I've been on linux for a few months now, but I struggle with scripts because I dont understand basic stuff like this.

thescrawl
Автор

Thank you Luke, i'm actually studying for the LFCS certification and videos like this one are a great resource !!!

juliotencio
Автор

This content will never get old. All LINUX newbies should see this to begin exploration of SED, regular expressions and AWK.

jamesfraser
Автор

Thank you so so much! Your skills show through when explaining. Einstein said something like, If you can't explain it to a five-year-old, then you don't understand it yourself. Awesome video!

michellemn
Автор

The syntax you used for providing multiple expressions to sed ( sed ) works with GNU, but it's non-standard. Not every implementation of sed can handle that. The standard way afaik is to do sed -e 'expression' -e 'anotherexpression'

anastaziuskaejatidarjan
Автор

It' amazing how he organize and sort everything. Because of him, my i3 looks beautiful. Thank you Luke for videos like this... 😁

cigimigi
Автор

I would be interested in videos about grep/pgrep and awk too! These small videos just show the peak of the iceberg of what's possible with these utilities but you showcasing a real-world-example gave me an idea what i could use sed for; i guess it got me started and woke my interest! Having similar videos for other useful utilities would be really nice!

timhilt
Автор

This is extremely helpful. I didn't realise that a lot of these sed commands are the same in vim, this greatly reduced the learning curve for me

mosukiton
Автор

This is so thorough. Exactly what I've been looking for!

MsSemki
Автор

I love how you make everything so simple

tc
Автор

The substitute command in vim is very similar but generally used with line ranges and can work with visually selected blocks, or from courser plus n lines.
:%s/a/b/n # % is shorthand for all lines, n just prints number of matches no actual change
:3, 12s/a/b/c # lines 3 to 12, c is the confirm-each flag which highlights and asks before doing

mytech
Автор

I'm once again impressed by how knowledgeable Luke is o.O. Thank you Sir Luke.

philome
Автор

Cool as, been waiting for a sed/awk video

marcussmithwick
Автор

Sometimes, unintentionally, people leave blank lines with trailing whitespaces (you will see them in visual mode, but the "s/^$/ d" won't). So, it would be safer to delete blank lines like that: "s/^\s*$/ d"

KupriyanovKirill
Автор

I have a funny(for me) story about sed. Me and my mentor wrote a script to setup a DNS server just because we were curious if we could do it. We could but had to replace " to ' and had to thinker a bit to figure it out that we should have used sed to replace them. It was a good experience

sorachii