Linux Crash Course - The sed Command

2021 ж. 19 Там.
111 920 Рет қаралды

In this episode of Linux Crash Course, we explore the sed command. sed, aka the "stream editor" is an underused command, and that's a shame because it's extremely useful for manipulating text. In this video, I'll show you the basics of the sed command.
LearnLinuxTV Sites
🐧 Main site:
➡️ www.learnlinux.tv
🐧 LearnLinuxTV Community:
➡️ community.learnlinux.tv
Support LearnLinuxTV (commission earned)
☁️ Support LearnLinuxTV and Set up your own cloud server with Akamai Connected Cloud:
➡️ learnlinux.link/akamai
📖 Check out Jay's latest book, Mastering Ubuntu Server 4th Edition. Covers Ubuntu 22.04!
➡️ ubuntuserverbook.com
🙌 Support me on Patreon and get early access to new content!
➡️ learnlinux.link/patron
🛒 Affiliate store for Linux compatible hardware/accessories:
➡️ learnlinux.link/amazon
💻 Check out the Tiny Pilot KVM for your Homelab:
➡️ learnlinux.link/tinypilot
About Me
🐦 Follow me on Twitter!
➡️ learnlinux.link/twitter
👨 More about me:
➡️ www.jaylacroix.com
➡️ www.learnlinux.tv
Recommended evergreen videos:
💽 How to create a bootable flash drive for installing Linux
➡️ linux.video/flash-usb
🐧 Understanding Linux permissions
➡️ linux.video/perms
🐧 OpenSSH Guide
➡️ linux.video/ssh
📖 LVM Deep-dive:
➡️ linux.video/lvm
🔐 How to better secure OpenSSH:
➡️ linux.video/secure-ssh
☁️ How to create a cloud Linux server with Linode:
➡️ learnlinux.link/create-linode
FAQ
🐧 Which distro do I use?
➡️ learnlinux.link/mydistro
💽 My recording gear (commissions earned):
➡️ learnlinux.link/recording-stuff
#CLI#Linux #sed

Пікірлер
  • it's important to note that '-i' is a GNU only option - so it won't work on BSD or MacOS etc.

    @mezlo64@mezlo642 жыл бұрын
    • Just run into this, had to switch to gnu sed on my mac

      @martinschulz1778@martinschulz17782 жыл бұрын
    • oh that explains it all thnks

      @greendog105@greendog105 Жыл бұрын
  • I believe the 's' before the search pattern actually stands for "substitute", not "string".

    @fleborne@fleborne2 жыл бұрын
    • Yes you are correct

      @andromida81@andromida812 жыл бұрын
    • sed is called stream editor, which is what Jay said.

      @PS_Tube@PS_Tube Жыл бұрын
  • Great tutorial. Unlike many other KZheadr's you don't overcomplicate things. Linux at it's core is made out of a ton of simple idea's that become complicated when they all work together.

    @MakeItWork256@MakeItWork2565 ай бұрын
  • Your channel is one of those rare gems on KZhead

    @simfoo@simfoo2 жыл бұрын
  • I love these short session. Very codensed helpful stuff. Thanks Jay!

    @TradersTradingEdge@TradersTradingEdge2 жыл бұрын
  • love seeing new videos like this for new people to linux. Jay's content is fantastic

    @mason8714@mason87142 жыл бұрын
  • you explain stuff very well and simple that makes it easy to grasp! thank you for sharing!

    @villico3@villico32 жыл бұрын
  • Finally, a way to easily remove pineapple from pizza topping lists.

    @crazyivan315@crazyivan3152 жыл бұрын
    • Couldn’t agree more. Pineapple as a topping? HECK NO!!

      @manny8717@manny87172 жыл бұрын
    • Pineapple are good, so is feta. It should change it to both.

      @yewenyi@yewenyi7 ай бұрын
  • Thank you Jay Linux is really vast, I just had my certification and I never heard of sed command. I'm glad your putting content for us.

    @Ray_TambaBudol_Marcos@Ray_TambaBudol_Marcos Жыл бұрын
  • I've just suggested the topic on your new video and saw this covered already afterwards. Thank you!

    @Rebel101@Rebel1012 жыл бұрын
  • Finally!!! 🔥 🔥 🔥 Thank you Sir for put the effort in making these amazing videos

    @TR1ckY_TV@TR1ckY_TV2 жыл бұрын
  • This is my first video, that i watched on your channel. You have explained it very nice and clear.

    @BilalKhan-rm8qk@BilalKhan-rm8qk Жыл бұрын
  • Thanks man that's what I needed to know. Glad the video was short and to the point.

    @brandonhunter3036@brandonhunter3036 Жыл бұрын
  • I tried to understand sed for years. I guess now I've got it. Thank you

    @Ollital@Ollital2 жыл бұрын
  • You make understanding the basics so clear!

    @alastairtheduke@alastairtheduke3 ай бұрын
  • This tutorial is amazing. Well done.

    @the-baker@the-baker Жыл бұрын
  • This makes that sudoers line make all the sense now. I used to be afraid of sed, but now I can shell script more effectively. Thanks!

    @jefferson4245@jefferson4245 Жыл бұрын
  • Simple and straight forward, thanks man

    @devilmaycry0204@devilmaycry0204 Жыл бұрын
  • Not all heroes wear cape. Great videos. Go buy this man's book too

    @anthonychaple3031@anthonychaple30312 жыл бұрын
  • Doing linux webserver support for well over a decade, sed became a go-to tool for flipping switches in config files. That said, I know its a lot more powerful than what I ever did with it.

    @shabadabadoo4326@shabadabadoo43262 жыл бұрын
  • Thank you for very clear presentation and explanation.

    @mnmleung@mnmleung Жыл бұрын
  • Happy to found this channel,

    @kazishafin1@kazishafin12 жыл бұрын
  • Great explanation.. subscribed😊.. One video is enough to understand the teacher's ability...

    @VijayaBaskarvvk@VijayaBaskarvvk Жыл бұрын
  • 👍👍👍👍👍 Thanks! This is a great first-step into the wonderful world of /sed/.

    @bobwong8268@bobwong82682 жыл бұрын
    • You sed it

      @dillon1012@dillon10122 ай бұрын
  • Wow new subscriber. Really good explanation! TY

    @vladimirtorres1181@vladimirtorres11812 жыл бұрын
  • "maybe I'm just hungry, I have no idea why I decided to use pizza toppings as the basis for today's video, but you know what, I did what I did and here it is" it made my day

    @dorotamartyniuq5553@dorotamartyniuq55532 жыл бұрын
  • thanks for your effort and explanation

    @dalirch8496@dalirch8496 Жыл бұрын
  • You are awesome mr. Lacroix. The best Linux guy ever

    @polliluiz@polliluiz Жыл бұрын
  • Fantastic explaination... Thank you Sir...

    @busyrand@busyrand2 ай бұрын
  • Amazing command and tutorial thanks

    @elnurvalikhanli6783@elnurvalikhanli6783 Жыл бұрын
  • thank you sir, very helpful

    @venkateshiyer5073@venkateshiyer50739 ай бұрын
  • sed 's/\/etc//' paths.txt Yeah, the command can get rather ugly when lots of escaped characters are needed, but it works and it's second nature for me since I often search for spaces and other characters that must be escaped anyway. Still, I appreciate that there is such an option in case someone wants to learn/use a different delimiter. Thanks for the video

    @larrywilliams8010@larrywilliams80102 жыл бұрын
  • Great explanation!

    @YannMetalhead@YannMetalheadАй бұрын
  • Hi Jay, LOVE your videos! Thank you so much for sharing your knowledge. please consider adding a video on the "w" and "who" commands. I realize it looks kind of obvious, but I am a total beginner in linux and your explanations of commands are the best. Looking forward to keep on learning.

    @guypartush2976@guypartush29765 ай бұрын
    • I completely agree that would be a great fit for my series. I will add it to my list.

      @LearnLinuxTV@LearnLinuxTV5 ай бұрын
  • That was very helpful. thanks

    @danperrault@danperrault Жыл бұрын
  • Thank you for showing syntax

    @riccoc.6507@riccoc.65072 жыл бұрын
  • You are a genius!!!!! Than you 4 teaching me!!!

    @linuxdoesmatter5542@linuxdoesmatter55425 ай бұрын
  • Thanks Jay.

    @guilherme5094@guilherme50942 жыл бұрын
  • Sed is command that I couldn't understand when I was beginner. I learned it but did not understand. After few months of writing sed s/... I noticed that I understand what I was writing.

    @thalcave8220@thalcave82202 жыл бұрын
  • Nice...very useful

    @sivaprasadk4756@sivaprasadk4756 Жыл бұрын
  • Good morning, Jay. Thank you very much for the detailed guides ! I have an old Toshiba Portege 14" Laptop with Kali 10.04 still installed there. Recently, I wanted to use it for a monitoring device and reinstall it but it is giving the "no pae"- error (common for the very old hardware). It doesn't boot from USB, only from CD/DVD. Do you think, I can still use it to install a Linux OS on it (I wouldn't mind being only CLI - I need it just to be able to install software to monitor my network), and which one you would propose if yes ? Thank you in advance. Asen

    @itbook182@itbook1822 жыл бұрын
    • You could use a distro which doesn't require pae or install an older version of kali and then upgrade it

      @swarooprajpurohit110@swarooprajpurohit1102 жыл бұрын
  • Awesome 🥰

    @ismaeelhaider3075@ismaeelhaider30754 ай бұрын
  • I didn't know that you could change the delimiter to a different character. this would have come in handy last year when I took a Unix/Linux course at college

    @billquain2369@billquain23692 жыл бұрын
    • Incredible information that sed delimiter can be something other than / I too had no idea. I look fwd to using other delimiters with sed.

      @chromerims@chromerims8 ай бұрын
  • Wondering what would be the script if I want to replace only the last occurance in the last line of the word Pineapple with Olives in your example file ?

    @muralikrishna9748@muralikrishna9748 Жыл бұрын
  • '...something EXTREMELY WRONG with this file.' LOL I'm with you, Jay. Pineapple on pizza--I'm OUT. Thanks for the help on delimiters.

    @user-gm6ok9iq8e@user-gm6ok9iq8e7 ай бұрын
  • Thank u so much.

    @mohamedhussien4013@mohamedhussien401311 ай бұрын
  • Thank you

    @Acksakal@Acksakal2 ай бұрын
  • I asked a college professor what sed was and I could not get a straight answer from him. Thanks Jay, now I understand. Thank you for posting.

    @rcdenis1@rcdenis12 жыл бұрын
  • oh man... we can use any delimeter!! not only / !!! Thank you! )

    @vladimirkulakov8667@vladimirkulakov866710 ай бұрын
  • Nice!

    @khomo12@khomo122 жыл бұрын
  • Fantastic

    @narayangurung7090@narayangurung70904 ай бұрын
  • I just love that comment about Pineapple as a Pizza topping! Hell No! I couldn't agree more 🙂

    @freyclante1766@freyclante1766 Жыл бұрын
  • I want to eat a pizza now 😂🤣😂🤣😂🤣😂🤣😂😂🤣😂🤣🤣🤣

    @nobilkwt7222@nobilkwt72222 жыл бұрын
    • Pineapple pizza ?

      @xrafter@xrafter2 жыл бұрын
  • Thank you very much

    @AM-cz7qy@AM-cz7qy5 ай бұрын
    • You are welcome

      @LearnLinuxTV@LearnLinuxTV5 ай бұрын
  • The word sed means thirst in Spanish. So have some Pineapple juice. Thanks I've set a goal to get better at the terminal so this helps.

    @ccroy2001@ccroy20012 жыл бұрын
  • I have a sub-string in a line e.g. id=84. How to use the sed command to 'read' the number immediately after the "id=" and dump it into a variable?

    @kychemclass5850@kychemclass58507 ай бұрын
    • Idk

      @buysnoah@buysnoah5 ай бұрын
  • How do you undo if find and replace was wrong? Notepad++ can find and replace across all files from ui. You don't need Unix command for that. Also it can undo it. Can you undo from unix????

    @chessmaster856@chessmaster856 Жыл бұрын
  • Thanks

    @chandrashekars9855@chandrashekars98552 жыл бұрын
  • Great Job .... but more more on sed and awk .. thanks - oldtony

    @tonyfreehauf4463@tonyfreehauf4463 Жыл бұрын
  • "What are some cool cli apps?" "sed and awk"

    @oldpain7625@oldpain76255 ай бұрын
  • thanks mate for suspenseful tutorial

    @janekmachnicki2593@janekmachnicki2593 Жыл бұрын
  • good job

    @hailelove1@hailelove1 Жыл бұрын
  • Thanks.

    @kythrathesuntamer9715@kythrathesuntamer971510 ай бұрын
  • I use sed to edit edit the output of a pip command that updates all my outdated python packages. The output goes to a xargs command

    @pnachtwey@pnachtwey2 жыл бұрын
  • Thank you, Jay.

    @AnzanHoshinRoshi@AnzanHoshinRoshi2 жыл бұрын
  • Thank u

    @subee128@subee1283 ай бұрын
  • He sed, She sed......................I'll see myself out......

    @MaximumRD@MaximumRD2 жыл бұрын
    • sed what?

      @voodooyam@voodooyam2 жыл бұрын
  • what about a video about chroot

    @nobilkwt7222@nobilkwt72222 жыл бұрын
  • et(44)1,tet(37)1,oqxB1,VanX-D4,VanX-D4,tet(O)2,aadA51,VanR-G1, here how can I remove everything that comes only after the bracket () by using sed??

    @shajibdey6451@shajibdey6451 Жыл бұрын
  • what is the difference between -i and -i.bak ?

    @tolstoievski4926@tolstoievski4926 Жыл бұрын
  • rude Jay! Pineapple is the GOAT on pizza!!

    @strifef7@strifef72 жыл бұрын
  • i was playing around with it to change one letter in a word to another letter and it worked but only in the first word in each line with the letter. Other occasions of the letter remain unchanged

    @debeeriz@debeeriz2 жыл бұрын
    • found out how add a g for global quidsup explains it in more detail

      @debeeriz@debeeriz2 жыл бұрын
  • Not sure ordinary mortals can master both sed and awk.

    @john-r-edge@john-r-edge2 жыл бұрын
  • how about the /g at the end? chatGPT tells me that if you don't add /g at the end, it will only substitute the word once per line, which may not be enough

    @antoineweb1@antoineweb13 ай бұрын
    • for example: echo "a a" | sed s/a/b/ gives "b a" as output

      @antoineweb1@antoineweb13 ай бұрын
  • i had issues only because i left out the / after feta (feta/)

    @terraflops@terraflops7 ай бұрын
  • And what, may I ask, is wrong with Pineapple?

    @adammureiko7508@adammureiko75082 жыл бұрын
  • now i can proceed w automations

    @noeelreeds@noeelreedsАй бұрын
  • 3:10 instant like

    @Blubberland@Blubberland Жыл бұрын
  • The option i followed by a suffix creates a backup = -i.bak this is important as -i can be dangerous.. :)

    @derekfrost8991@derekfrost89912 жыл бұрын
  • Ty

    @EduardoReyesDPM@EduardoReyesDPM2 жыл бұрын
  • I have data like "Chair"||"Table"|||"Sofa".. How to add double quotes between each pipeline like "Chair"|""|"Table"|""|""|"Sofa" .. Please let me knw the command

    @navasr7969@navasr7969 Жыл бұрын
  • I think the s stands for substitute not string

    @Ranblv@Ranblv2 жыл бұрын
  • Awesome again. Now I have awk sed & $bash ?

    @srsr6099@srsr60992 жыл бұрын
    • ّ

      @xrafter@xrafter2 жыл бұрын
    • bash: Now: command not found

      @xrafter@xrafter2 жыл бұрын
    • sudo apt-get update, could help

      @srsr6099@srsr60992 жыл бұрын
  • Oh no, no, no. I must change every topping to pineapple. This is not allowed to stand. Thanks for showing me how to use sed to do that. You are very kind, but very wrong.

    @BlindRambler@BlindRambler2 жыл бұрын
  • 👍👍👍

    @srb1855@srb1855 Жыл бұрын
  • You sed yes, I sed no You sed stop and I sed go go go, oh no You sed goodbye and I sed hello Hello hello I don't know why you sed goodbye, I sed hello Hello hello I don't know why you sed goodbye, I sed hello

    @brentrambo2571@brentrambo2571 Жыл бұрын
  • Thanks for your vedios. I am stuck in a problem . My XMl FIle contains data like : 1234 2345 8787987 89898 80098 I want to arrange my xml file such that the tags and should be in a single line without space. 1234 2345 8787987 89898 80098 Tried many sed commands but no luck.Please help me to resolve it .

    @vikasmahour6059@vikasmahour6059 Жыл бұрын
  • ‘sed’ is short for ‘stream editor’, for those who’re wondering what the command means.

    @stevenoderayi5776@stevenoderayi57762 жыл бұрын
    • it was said in the video. thanks anyway.

      @markchristophergemzon1052@markchristophergemzon1052 Жыл бұрын
  • video starts at 2:00

    @sidouglas@sidouglas Жыл бұрын
  • CHICKEN PINEAPPLE PIZZA IS THE BEST and PERIOD!

    @ivanm9186@ivanm91866 ай бұрын
  • The pizza example reminded me of a video I saw a long time ago where this guy made a command line Dominos pizza ordering program. kzhead.info/sun/fZpyYcWEnZ2Ng2g/bejne.html BTW I love your videos. You are like the Bob Ross of Linux.

    @MRF442@MRF4422 жыл бұрын
  • as a pizza delivery driver who is an aspiring linux user, This tutorial was perfect. that being said, Pineapple_Pizza = "The Best"

    @redshepard5306@redshepard53062 жыл бұрын
  • Is Unix dinosaur or not?

    @chessmaster856@chessmaster856 Жыл бұрын
  • 1:22

    @subtitles1492@subtitles14922 жыл бұрын
  • You have to understand. Unless you can make ordinary devices work, like Bluetooth.. You will always be a third choice. I need to use Bluetooth, and it only stays connected for on average 15 mins. At least printers use the web browser printer settings, else that would be another thing , that doesn't work on any Distro I have used just about every Distro out there, none have lasted for over a year except Linux Mint

    @marcravey4621@marcravey46212 жыл бұрын
  • First

    @poojithapriya2370@poojithapriya23702 жыл бұрын
  • i felt that a can cheat the machine... stupid machine... lol

    @paulojr1384@paulojr1384 Жыл бұрын
  • anti pineapple people will always be weak

    @icyjiub2228@icyjiub2228 Жыл бұрын
  • You just lost all credibility for disliking pineapple🤪

    @alexhu98@alexhu982 жыл бұрын
  • Good video, liked it very much but sorry man, I had to click the dislike button... pineapple absolutely BELONGS on pizza!

    @Thr0nSK@Thr0nSK Жыл бұрын
KZhead