sed: Easily replace strings across files | #7 Practical Bash

Sdílet
Vložit
  • čas přidán 20. 08. 2019
  • How do you replace easily replace strings across your entire code base? Now please don't say "My IDE has a feature for that". Of course, there's a simple way to do it with the terminal with the built-in command "sed". Another omni-present command that can be so helpful in everyday coding work, scripting, refactoring and all other string replacement needs.
  • Věda a technologie

Komentáře • 22

  • @trashchris
    @trashchris Před 3 lety

    My first attempt at replacing strings with sed and my current example has / in the replacement, massive help!

  • @JamesRamptonUK
    @JamesRamptonUK Před 2 lety

    Great work on this series, really helpful. One tip I learned: to save the hassle of deleting all those .bak files on macos, you can say sed -i '' (two single quotes) and no new files will be created. Anyway, I look forward to watching the rest of these!

  • @Norfeldt
    @Norfeldt Před 3 lety

    These videos has been a really great help to me. Thank you so much 🙌
    How do you get the bottom theme bar for you tmux session?

  • @breakfastpipeline3113
    @breakfastpipeline3113 Před 4 lety +3

    A video on your dev environment (dotfiles, vim and terminal setup, etc) would be very cool. Great video!

    • @kubucation
      @kubucation  Před 4 lety +3

      On the list. The past few weeks have been unusually busy (with non-Kubucation work), so I haven’t had the time to create new videos yet - but this is one I‘m definitely planning on making.

  • @neethology
    @neethology Před 2 lety

    you should do awk, love the way you teach.

  • @michaelhajny1348
    @michaelhajny1348 Před 3 lety

    May I ask you is there a chance that you will make similar video but instead of sed you try explain awk ?

  • @ashiksoman4411
    @ashiksoman4411 Před 2 lety

    Hi Sir, how to specify the row number and column number in sed command?
    Pls help me!!

  • @Norfeldt
    @Norfeldt Před 3 lety +1

    Thank you very much for these great tutorials on bash basic - I find them very useful! Sometimes you switch the command your are currently writing to vim and then back again - how do you do that? And can it be done with other code editors?

    • @kubucation
      @kubucation  Před 3 lety +1

      Yes, this should work with whichever editor you have set in your EDITOR env var. I press Ctrl-x-Ctrl-e (as in hold Ctrl and press x, release x, keep holding control, then press e). I think this is actually an emacs feature, so your shall has to be configured to emacs bindings (most are by default).

    • @kubucation
      @kubucation  Před 3 lety

      And thank you for liking the tutorials :-)

    • @Norfeldt
      @Norfeldt Před 3 lety

      @@kubucation It WORKS! thank you very much!

  • @zinhlenxumalo1450
    @zinhlenxumalo1450 Před 2 lety

    Hi I want to replace something that has a pattern so I have files with eg. .....1_....: and I want to remove what is after the '_' so my output would be ....1:

  • @robinreso6240
    @robinreso6240 Před rokem

    How can i change $var=123456 to $output=12:34:56:00 with sed? I hope it can be done very easily with a one-liner? if not sorry for asking, then maybe you can give me some pointers to solve this problem. thx

  • @devourerification
    @devourerification Před 3 lety

    How did you switch to cli output on 1:32?

  • @batchrocketproject4720

    FIrst week in new job surrounded by shmython gurus, volunteer for the 'long day' task to fix the spelling error in 12,000 files, home before morning tea break. 😀

  • @herp_derpingson
    @herp_derpingson Před 4 lety +9

    Why so sed?

  • @srajanjain2541
    @srajanjain2541 Před 3 lety

    sed life ! but it's ok 😁 🤣😂🤣

  • @tdhxgstgshhdhxg8885
    @tdhxgstgshhdhxg8885 Před 3 lety

    Omg