Learning Sed Is Beneficial For Linux Users

Поделиться
HTML-код
  • Опубликовано: 23 июн 2021
  • sed is a stream editor. A stream editor is used to perform basic text transformations on an input stream (a file or input from a pipeline). The most common usage of sed involves substituting a pattern or string for another string. But sed can be used for many tasks. It's a powerful command line utility that should be in everyone's tool bag.
    REFERENCED:
    ► www.gnu.org/software/sed/manu... - Sed Manual
    WANT TO SUPPORT THE CHANNEL?
    💰 Patreon: / distrotube
    💳 Paypal: www.paypal.com/cgi-bin/webscr...
    🛍️ Amazon: amzn.to/2RotFFi
    👕 Teespring: teespring.com/stores/distrotube
    DONATE CRYPTO:
    💰 Bitcoin: 1Mp6ebz5bNcjNFW7XWHVht36SkiLoxPKoX
    🐶 Dogecoin: D5fpRD1JRoBFPDXSBocRTp8W9uKzfwLFAu
    📕 LBC: bMfA2c3zmcLxPCpyPcrykLvMhZ7A5mQuhJ
    SOCIAL PLATFORMS:
    🗨️ Mastodon: distrotoot.com/@derek
    👫 Reddit: / distrotube
    📽️ LBRY/Odysee: odysee.com/$/invite/@DistroTu...
    DT ON THE WEB:
    🕸️ Website: distrotube.com/
    🐿️ Gemini Capsule: gemini://distro.tube
    📁 GitLab: gitlab.com/dwt1
    FREE AND OPEN SOURCE SOFTWARE THAT I USE:
    🌐 Brave Browser - brave.com/dis872
    📽️ Open Broadcaster Software: obsproject.com/
    🎬 Kdenlive: kdenlive.org
    🎨 GIMP: www.gimp.org/
    🎵 Audacity: www.audacityteam.org/
    💻 VirtualBox: www.virtualbox.org/
    🗒️ Doom Emacs: github.com/hlissner/doom-emacs
    Your support is very much appreciated. Thanks, guys!
  • НаукаНаука

Комментарии • 147

  • @nbn22385
    @nbn22385 3 года назад +78

    Drink every time dt says "let me clear the screen" 😁

    • @Thomas-rl8kw
      @Thomas-rl8kw 3 года назад +6

      I took a drink every time he said sed 's/sed/replace/g' drink

    • @zero0bb
      @zero0bb 3 года назад +5

      Nlt dtrunk weeyt

    • @TheBlueThird
      @TheBlueThird 3 года назад +1

      Drinking....

    • @beingpravas
      @beingpravas 2 года назад

      But... Um...

  • @gordonbai5320
    @gordonbai5320 3 года назад +65

    sed and AWK are the first two tools I learned in undergraduate Linux class. They are so important, glad to see some brilliant recaps from DT!

    • @tweakernation
      @tweakernation 3 года назад +3

      @@try1785 I'm pretty sure any college with a Computer Science program has Linux classes

    • @gordonbai5320
      @gordonbai5320 3 года назад +1

      @@try1785 It's a class called Computer Software and System, sound pretty generic but it only focused on UNIX-like OS usage and history. The professor at the time was like, hey I think our students need to know these so let's open this course. Guess it varies among colleges. Now students have more choices, like DT's videos or MIT's popular 'missing semester'.

    • @Gornius
      @Gornius 3 года назад

      @@tweakernation I had Linux class, but used sed and awk more on Cybersecurity class, where we had to write many bash scripts.

    • @akileswar114
      @akileswar114 Год назад

      @@tweakernation we never had :_)

  • @jochebed8342
    @jochebed8342 3 года назад +42

    I really appreciate your high quality content. That takes Linux to a really high level!

  • @Speykious
    @Speykious 3 года назад +28

    What works when you want to search for a word is to use the boundary characters, which happen to be \< for left and \> for right.
    So if you search for the sequence \, it's gonna try to find the word red alone, not included in another word.

  • @masamune5710
    @masamune5710 3 года назад +20

    This title is way better than the one for the awk vid

    • @DevvratSingh007
      @DevvratSingh007 3 года назад +9

      That title was just awkward.

    • @alicethegrinsecatz1611
      @alicethegrinsecatz1611 3 года назад +2

      Except for Germans, because SED was the socialistic party which controlled the dictatorship in East-Germany build by the Soviets...

    • @SumriseHD
      @SumriseHD 3 года назад +1

      @@alicethegrinsecatz1611 DIE PARTEI HAT IMMER RECHT 😂

  • @Rh0mbus
    @Rh0mbus 3 года назад +4

    I love the new background and environment for your recording space! Looks so good!

  • @jamesbrasington8559
    @jamesbrasington8559 Год назад +4

    This guys channel I just discovered and it is highly underrated. Love the clarity and explanations of everything with lots of examples. Thank you.

  • @crazychicken0378
    @crazychicken0378 3 года назад +7

    I knew this was coming as soon as I saw the awk tutorial. Great content, I appreciate it

  • @BrucesWorldofStuff
    @BrucesWorldofStuff 3 года назад +3

    I just love watching everyone's take on AWK & SED @DistroTube... So much fun an info once more!
    Loved the little joke at the end... Lol Lol Lol
    Thanks DT for the video!
    LLAP

  • @PrashantKumardaniel
    @PrashantKumardaniel 3 года назад +1

    Your videos are very comprehensive and upto the point. Keep it up

  • @ChucklesMcGee780
    @ChucklesMcGee780 Год назад

    brother DT, i want to thank you for making these videos.
    i swapped over full time to linux around 2 months ago.
    your videos have taught me so much, and i now have a desktop that looks incredible, that does incredible things.
    hands down my favourite linux creator in the tube.
    keep up the amazing work!!!!!

  • @sys7emH4cked
    @sys7emH4cked Год назад

    I recently saw your sed and awk command tutorials both are really helpful. Thank You ❣️ D.T, for making this useful tutorials .

  • @arrtemfly
    @arrtemfly 3 года назад +2

    that's a very nice tutorial! thanks
    also i've noticed the lighting looks like you're in a proper studio on a photo shoot or something, cool stuff

  • @commentarysheep
    @commentarysheep 5 месяцев назад

    I knew all of the other Linux CLI utilities, but I always found the syntax of ‘sed’ funky.
    Thank you for your excellent explanation, DT!
    It’s way more efficient than using my text editor’s built-in search and replace feature!

  • @voytechj
    @voytechj 3 года назад +5

    When creating sed regex expression it's a good idea to check what has been modified:
    $ sed '...' inputfile | diff inputfile
    you can pipe it further to a program that colorizes text:
    $ sed '...' inputfile | diff inputfile | bat -l diff
    For vim users you can use vimdiff (easier side by side comparison), but "process substitution" has to be used to trick vim that pipe is a file:
    $ vimdiff inputfile

  • @n0kodoko143
    @n0kodoko143 3 года назад +1

    Stream editor goodness! Thanks DT

  • @AlastairMontgomery
    @AlastairMontgomery 3 года назад

    Been using sed for years, it's always good to watch how other people use it, you tend to pick up a few things you didn't know.

  • @TheSulross
    @TheSulross 3 года назад +3

    when -i option was added to sed, that was life changing - and that can use -e to specify multiple expressions to apply on the stream - sed is kind of like the single most potent unixy power tool

  • @oneanime5551
    @oneanime5551 3 года назад +1

    Thank you so much for this video!!! Really appreciated

  • @ilshatt
    @ilshatt Год назад +1

    What a nice function, thanks for the explanation!

  • @chuckliddell6492
    @chuckliddell6492 3 года назад +1

    you posted this as I was trying to write a script to use pywal with lightdm-mini thanks dt

  • @mitchelvalentino1569
    @mitchelvalentino1569 3 года назад +30

    Srs, if you want to see some masterful sed code, check out games written in sed. Tetris, Breakout, Chess, etc. It’s humbling and trippy looking at the source.

    • @BrucesWorldofStuff
      @BrucesWorldofStuff 3 года назад +2

      Really! That's interesting... :-D
      LLAP

    • @mitchelvalentino1569
      @mitchelvalentino1569 3 года назад +2

      @@BrucesWorldofStuff LLAP 🖖

    • @VvC_Lad
      @VvC_Lad 3 года назад +1

      Wait that’s possible? I thought sed’s only for substituting and replacing

  • @Eydamos
    @Eydamos 2 года назад +2

    I recently saw your awk video and now this sed video. Both are really great and I have learned a lot. Just one thing I want to point out as I had this issue just this week:
    If you have a big file e.g. let's say 3Gb log file and want to have 1000 line starting at line 30000 sed is a lot quicker then awk with this.
    In my test `sed -n '30000,31000p' file.log` took like 3 seconds while `awk 'NR==30000,NR==31000 {print $0}' file.log' took almost a minute

  • @greatmonk
    @greatmonk 3 года назад

    hey it was a very good session.. Thanks for this. I am going to watch your awk next...

  • @Kavinnathcse
    @Kavinnathcse 2 года назад

    Awesome tutorial about sed .. Single stop for learning sed ..

  • @matthewdee6023
    @matthewdee6023 3 года назад +1

    'Pro' tip: most shells will clear the screen when you hit CTRL-L :)
    [edit] Oh, and CTRl-A and CTRL-E will take you to the beginning/end of the line (i.e. Emacs navigation commands).

  • @mohammadrezaabbasi4841
    @mohammadrezaabbasi4841 2 года назад

    amazing course .thx dude

  • @thelostrider1
    @thelostrider1 3 года назад +4

    Would love to see DT talk more about shell scripting but in a more advanced way

  • @Shuliba
    @Shuliba 3 года назад +4

    Learning regex changed my life.

  • @1MinuteFlipDoc
    @1MinuteFlipDoc 3 года назад +1

    your audio quality is good (again!)

    • @littlepeon
      @littlepeon 3 года назад +1

      It's ok here, but can tell the gain is way up, it's max-ing out and causing DT to sound like he has a lisp at the end of most sentences!

  • @bhaveshverma8629
    @bhaveshverma8629 3 года назад +1

    Very very good sir. Keep up good work sir.

  • @Yesdin007
    @Yesdin007 2 года назад

    thank you man , so important command

  • @amirammar6687
    @amirammar6687 2 года назад

    I found your video so useful!

  • @jabarasadi3063
    @jabarasadi3063 2 года назад +1

    awesome man!

  • @l00t_t00l
    @l00t_t00l 3 года назад +2

    Third!

  • @paulofreireslaw
    @paulofreireslaw 3 года назад +1

    Thanks, studying this cmd in school atm

  • @tecbs
    @tecbs 3 года назад +1

    thanks.. high quality content

  • @altermetax
    @altermetax 3 года назад +1

    If you want to search for a word instead of a string, surround the word with \b. For example: sed 's/\bred\b/green/'

  • @damian_madmansnest
    @damian_madmansnest 7 месяцев назад

    for me an eye opener on sed was learning vim’s ex mode.
    sometimes it’s even faster to filter lines in vim through sed instead of running a similar vim ex command.

  • @bahathir_
    @bahathir_ 3 года назад +2

    For GNU Sed, we can use the input's file name directly, without using '

  • @fennecbesixdouze1794
    @fennecbesixdouze1794 Год назад

    If you're using GNU then you can match an exact word using /\bword\b/. The anchor "\b" represents a word boundary. You can also use /\/.

  • @virabadrasana
    @virabadrasana 2 года назад

    Really good! Thank you. I learnt a llot of tricks. One thing I would have liked to see included is capture groups. How do you capture specific strings? Top quality, thanks!

  • @danielugalde5999
    @danielugalde5999 11 месяцев назад

    Thank you bro!

  • @YannMetalhead
    @YannMetalhead 3 месяца назад

    Good video!

  • @chinonsoagueze4992
    @chinonsoagueze4992 Год назад

    I’m a beginner and this video opend my brain 🧠

  • @MCgranat999
    @MCgranat999 3 года назад

    When you made the video on Awk the forest thing that came to my mind was Sed

  • @alirezahassani8646
    @alirezahassani8646 2 года назад

    Hi sir
    useful video about sed.
    tnx

  • @hamedmahdavifar2293
    @hamedmahdavifar2293 2 года назад

    amazing . thank you.

  • @Nyarkfunky
    @Nyarkfunky 5 месяцев назад

    Thx for your work. 🐧🦎🐧

  • @markgreen2170
    @markgreen2170 3 месяца назад

    nice, thanks!

  • @mpotane
    @mpotane 3 года назад

    I want to add this sed, I use this to edit my host file. This will essentially add a line of text after the first match pattern. For example ==== sed -i '0,/pattern/!b;//a[the text u want to add]' filename

  • @ceres11
    @ceres11 3 года назад +1

    18:00 you can do this with head (and even tail) too by writing "head +15 test.txt"

  • @nicholifamadico6619
    @nicholifamadico6619 Год назад

    Hi, may I ask how did you make your CLI show a type-ahead suggestion?
    Like for example when you started typing the command "sed", it already shows something like a format of what to type next in grey color.
    Is it from history?
    Thanks in advance!

  • @renyirish
    @renyirish 2 года назад

    Subscribed! :) Although you speak incredibly fast for a foreign person like me Lol you are awesome! Thanks a million, really appreciate all of your great contents that I'm going to go through at any spare time I have ;) Have a great Easter holidays!

  • @fuahuahuatime5196
    @fuahuahuatime5196 2 года назад

    Had to replace hundreds of lines in a file with duplicate lines because a lazy coworker wouldn't do it themselves. Never again. Thanks for the video.

  • @matiasm.3124
    @matiasm.3124 3 года назад +2

    Well nice video .. how to delete one empty line if the next line is an empty line ? And for printing x numbers of line you can use head -n XX file and avoid sed/awk.

  • @Yggdra666
    @Yggdra666 3 года назад

    "sed 11q.. it's really just a poor mans awk NR 13"
    I gotta love your humor, DT.
    Makes for great lessons.

  • @liftlinux9421
    @liftlinux9421 3 года назад +1

    Now we need a digreen file manager

  • @ArvidDoerwald
    @ArvidDoerwald 3 года назад +6

    Must I write "first" if it happens to be so ?

    • @DistroTube
      @DistroTube  3 года назад +2

      Well, you did write it...

    • @joaonofap
      @joaonofap 3 года назад +2

      Lucky guy... I envy you.

  • @khomo12
    @khomo12 2 года назад

    Great!

  • @fabrice9848
    @fabrice9848 Год назад

    @13:21 I understand how this command works
    But I don't get why it doesn't work if we replace the * with a +
    we're looking for one or more spaces at the end of each line, so it should work when using + instead of *
    what am I missing here ?

  • @StephenMcGregor1986
    @StephenMcGregor1986 3 года назад

    hey DT, what do you think about the Level099Techs videos on Bash commands?

  • @corycaserta748
    @corycaserta748 11 месяцев назад

    Could someone please comment the name of the shell-color-script shown in this video, the random-colored histogram one? And can someone show where it can be downloaded? It doesn't seem to be on the DistroTube gitlab page. Thank you, Derek for awesome YT Linux content and instruction! Any further collections of shell-color-scripts would be much appreciated.

  • @shahradelahi
    @shahradelahi 10 месяцев назад

    Thanks for the video! I noticed some subtitle issues. Can they be corrected? Thank you sincerely.

  • @NNNPDawid
    @NNNPDawid 3 года назад +2

    Selection whole word i ezy in sed '\bword\b' gets whole word.

  • @jamesleimer2527
    @jamesleimer2527 2 года назад

    what linux distro do you use and also the desktop enviroment and terminal?

  • @IuliusPsicofactum
    @IuliusPsicofactum 3 года назад +1

    sed and unlimited power are synonyms.

  • @GuerreroMisterioso95
    @GuerreroMisterioso95 3 года назад

    Sed in Spanish means "be yourselves" (plural imperative second person of to be) or thirst

  • @killistan
    @killistan 3 года назад

    step 1: learn sed
    step 2: pull hair out trying to get |sed to stop corrupting filenames
    step 3: learn to use parameter expansion instead (usually)

  • @daniahmed
    @daniahmed 11 месяцев назад

    If i want to add a letter or a string at start of every line, then what would the command look like?

  • @pup4301
    @pup4301 3 года назад

    May you please do a video on just. Just is a command runner ment to fix some of the command runing problems of make. It really replaces make for me.

  • @GabrielMartinez-ez9ue
    @GabrielMartinez-ez9ue 3 года назад

    Is there a difference between:
    sed 's/find/replace/' < file1 > file2 //that i notice you use this redirect
    and
    sed 's/find/replace/' file1 > file2

  • @TheGodSchema
    @TheGodSchema 3 года назад

    This is way better than the grapes video.

  • @venusarathy6163
    @venusarathy6163 3 года назад

    hey dt, your opinions about windows 11 "the proprietary garbage"

  • @nkpytelzhor
    @nkpytelzhor 2 года назад +2

    I admire the cooperation of your rapid thinking and typing commands, but for me 0.75 speed is ideal.

  • @fabrice9848
    @fabrice9848 Год назад

    How did you customize your man pages ?

  • @kaineuler
    @kaineuler 3 года назад +5

    Hello dt , i know this may be far fetched but is there a chance you can make an iso of your arch with all the theming and text editors (emacs) and terminal configuration settings for your viewers. I really appreciate your arch setup.

  • @bujin5455
    @bujin5455 2 года назад

    It seems to use a non standard version of regular expressions.

  • @nateswissmusic
    @nateswissmusic 4 месяца назад

    what is the GUI being used here?

  • @olivermeissner5198
    @olivermeissner5198 3 года назад

    …I wonder how to replace all occurences of a period with a comma, before the first space in a line...

  • @kacperfilipek8461
    @kacperfilipek8461 3 года назад +1

    1:25 Why use < when you can just pass a filename as an argument to sed like this?
    sed 's/find/replace/' filename

    • @LHCB6
      @LHCB6 3 года назад

      Beginner's guide? Maybe just the syntax he's used to

  • @alexcricles
    @alexcricles 3 года назад

    so, what is the difference between regex and sed command?

  • @thedeathchimera
    @thedeathchimera 3 года назад +5

    Pssst... that’s what she sed...

  • @redd6231
    @redd6231 3 года назад +3

    In reality, dt's name isn't "Taylor" nor "Tyler", it's either "Tayler" or "Tylor".

    • @1MinuteFlipDoc
      @1MinuteFlipDoc 3 года назад +2

      I thought it was Tiffany?

    • @redd6231
      @redd6231 3 года назад +2

      @@1MinuteFlipDoc That's a good one ! But dt is wearing a shirt with "Marley" written on it so I guess it's his real name...

  • @EndrChe
    @EndrChe 3 года назад

    I immediately find “ampersign” to be a far superior word to ampersand.

  • @hernanfelipediaz566
    @hernanfelipediaz566 3 года назад

    I actually think that the space search pattern is not optimised, it is way better to use a '+' since it will only act when it is 1 or more instead of 0 or more. With '*', the command will make an action every single line, that's unefficient.

  • @mushtaqali5845
    @mushtaqali5845 2 года назад

    great tutorial but font too small for mobile phone

  • @AdroSlice
    @AdroSlice 3 года назад +1

    Well at least the title isn't as presumptuous as the last.

  • @MartinAhlman
    @MartinAhlman 3 года назад +1

    That's what she sed.

  • @RishiKumar-nz1tp
    @RishiKumar-nz1tp 3 года назад

    How's your man page colourful?

  • @ramongonzalezfernandez8904
    @ramongonzalezfernandez8904 3 года назад

    14:46 doesn't \s also work? (\\s)

  • @0xva
    @0xva 3 года назад

    10:40 sed 's/usr/u/g; s/bin/b/g' should also work.

  • @primechikweru3608
    @primechikweru3608 Год назад

    your 'i don't know' sounds like sheldon's

  • @verolyn8459
    @verolyn8459 2 года назад

    Is it only me always doing a extended regex for Sed even if its not actually needed? Lol.
    sed -E '...'

  • @uuu12343
    @uuu12343 2 года назад +1

    I am *sed* everyday

  • @supermanbanty3210
    @supermanbanty3210 10 месяцев назад

    What is this tldr??

  • @Thomas-rl8kw
    @Thomas-rl8kw 3 года назад +1

    sed is almost as awkward as the aptly named awk program.

  • @user-mb2es8rs5g
    @user-mb2es8rs5g 2 года назад

    Are you Tyler Derden?

  • @matt92hun
    @matt92hun 3 года назад

    Just use ed, the standard editor.

  • @VulcanOnWheels
    @VulcanOnWheels 3 года назад

    18:00 Not really, because you told sed to give you 11 lines. *confused*