How The 'awk' Command Made Me A 10x Engineer

Поділитися
Вставка
  • Опубліковано 10 гру 2020
  • Learning to use the 'awk' command increased my productivity significantly. awk allows me to quickly manipulate and inspect data in text files. This is especially true for column-based data, such as .csv files. Since awk is a fully functional programming language, I can quickly use awk to solve problems that are too complicated for programs like grep or sed.
    A text-based version of this video with all commands can be found here:
    blog.robertelder.org/intro-to...
    SOCIALS
    ----------------
    Patreon: www.patreon.com/RobertElderSo...
    Tiktok: / roberteldersoftware
    Linkedin: / robert-elder-software
    Blog: blog.robertelder.org/?...
    Twitter: / roberteldersoft
    Twitch: / roberteldersoftware
    Github: github.com/RobertElderSoftware
    Facebook: / roberteldersoftware
    Instagram: / roberteldersoftware
    Merch: store.robertelder.org/?...

КОМЕНТАРІ • 389

  • @user-uk9er5vw4c
    @user-uk9er5vw4c 3 місяці тому +105

    the narrative that lead to the tutorial is so cute as it never happened.

    • @Bjawu
      @Bjawu 3 місяці тому +16

      I sure hope so, or someone needs to learn about spreadsheets.

    • @elieobeid77
      @elieobeid77 2 місяці тому +5

      it never happened indeed and a maximum of 4 lines of python can do this, that's why I avoid learning these tools

    • @jazzochannel
      @jazzochannel 2 місяці тому +1

      spreadsheet? is that like lasagna or vegemite or nutella,@@Bjawu ?

    • @Bjawu
      @Bjawu 2 місяці тому +2

      @@jazzochannel There *are* some similarities with vegemite, now that I thing about it. You don't want to use too much.

    • @ChimeraBlockhead
      @ChimeraBlockhead Місяць тому

      I feel like people just don’t get this guy’s sense of humor

  • @nufosmatic
    @nufosmatic 3 місяці тому +47

    Many moons ago I helped maintain what we thought might be the largest awk script ever created - it converted between the proprietary FORTRAN code for compilers by our competitors into our own proprietary FORTRAN code. Of course, monthly, if not weekly, we'd find something it did not convert properly, and it would have to be changed. Not only was it possibly the largest awk script, but it was the most modified awk script...

    • @artemiasalina1860
      @artemiasalina1860 3 місяці тому +2

      Fascinating! Do you remember how many lines (roughly) it was?

    • @nufosmatic
      @nufosmatic 3 місяці тому

      @@artemiasalina1860 It was well over a thousand lines.

    • @bide7603
      @bide7603 3 місяці тому +4

      Sounds awk ward to work with…. I’m sorry

    • @nufosmatic
      @nufosmatic 3 місяці тому +1

      @@bide7603It's not funny, it's a way of life...

    • @somebody-anonymous
      @somebody-anonymous 2 місяці тому +5

      I once took a little boy under my wing who thought that text manipulation equated to social skills. He was a little awk ward

  • @josefaguilar2955
    @josefaguilar2955 3 місяці тому +43

    The awk command is now my favorite Linux command

    • @catsupchutney
      @catsupchutney 3 місяці тому +3

      I avoided Awk for 15 years, but then I saw the light.

    • @cinderwolf32
      @cinderwolf32 3 місяці тому +3

      ​@@catsupchutney I have a year left of avoiding it like the plague, maybe. Then I'll give it a shot.

  • @adam872
    @adam872 3 місяці тому +54

    Utilities like awk are one of the reasons I love Unix. Everything is in a text file and the OS gives you the tools to parse and manipulate the contents.

  • @cthyau
    @cthyau 3 місяці тому +26

    I used to use awk every day about 30 years ago. A nice walk down the memory lane with this video.

    • @jazzochannel
      @jazzochannel 2 місяці тому

      memory lane? why did you stop?

    • @cthyau
      @cthyau 2 місяці тому +1

      @@jazzochannelmy work now doesn’t involve coding and data manipulation any more.

  • @greob
    @greob 3 роки тому +94

    Thanks for sharing.
    Good luck with your 1% raise!

  • @brokenregime
    @brokenregime 3 місяці тому +49

    The solution to the original problem was a bit of overkill, but this was a good example for some teaching of base awk functionality. This is a more direct and shorter solution, only changing the F lines and printing all lines:
    $ awk '$2=="F" {$1=sprintf("%.1f",($1-32)/1.8); $2="C";} 1' temps.csv
    (the single "1" at the end is the condition, which evaluates as "true", evoking the default action: print -- nice shortcut if you mean only to change some lines but print all)

  • @tmanley1985
    @tmanley1985 2 роки тому +100

    I like how there was a narrative style to the video. That's really engaging. You've earned a sub!

    • @mjscpr
      @mjscpr Рік тому

      Great pace too.

  • @weaponkid1121
    @weaponkid1121 4 місяці тому +294

    I get that awk is a useful tool overall, but with your given example, why exactly would writing a program be time consuming?

    • @Temulgeh
      @Temulgeh 3 місяці тому +97

      i think it was just a poor attempt at a motivating example and a joke at the same time

    • @TheKuhtaMusic
      @TheKuhtaMusic 3 місяці тому +24

      the whole premise was quite funny

    • @jeanhaley3051
      @jeanhaley3051 3 місяці тому +35

      It would take as long to write in python as it would take learning awk. At least pre AI, now AI could generate the command in moments.

    • @Temulgeh
      @Temulgeh 3 місяці тому

      @@jeanhaley3051 i just tried writing that python script and measured how much time it took me (without trying to rush it), it took 1 minute. it might be faster with awk in the long run? but 1 minute is good enough for me

    • @utvikler-no
      @utvikler-no 3 місяці тому +12

      Even less code with Perl. And this example is not recommended at all. What happens when the data is changed. It all fails.

  • @BytebroUK
    @BytebroUK 3 місяці тому +23

    'awk', 'sed', and 'Perl'. All I ever need for scraping from log-files!

    • @GreyDeathVaccine
      @GreyDeathVaccine 3 місяці тому

      head and tail is also useful for a redneck like me :D

    • @obiwankenobe3962
      @obiwankenobe3962 2 місяці тому

      If you know Perl, do you still have a use for Awk? (I'm wondering if I should learn it, I already know Perl. From the looks of this video, I can do the same with Perl in maybe 20-30% more characters - not enough more to trigger learning it)

    • @BytebroUK
      @BytebroUK 2 місяці тому +1

      @@obiwankenobe3962 Sure. Back in the old Unix days you needed sed and awk to to text munging. Now I just use Perl for all of it. Perhaps more characters to type in, but much simpler syntax and easier to learn, IMO.

    • @obiwankenobe3962
      @obiwankenobe3962 2 місяці тому +1

      @@BytebroUK thx for confirming my suspicion

  • @kellybmackenzie
    @kellybmackenzie 3 місяці тому +27

    I enjoy using GREP and SED and I've been really wanting to learn how to use AWK. This video motivated me to do so, I'm gonna!! Also LOL, the end of the video made me laugh a lot. I love this!

  • @TON-vz3pe
    @TON-vz3pe 2 роки тому +28

    Wow.. I know awk well, but what a presentation. This is an underrated video. Keep it up dude.

  • @bide7603
    @bide7603 3 місяці тому +44

    Bro went from a 0x developer to a 0.5x dev

    • @Dante-420
      @Dante-420 3 місяці тому

      10x0 is still 0

    • @cleverhippo
      @cleverhippo 3 місяці тому +4

      what a hater, the video was great

    • @aimpizza6823
      @aimpizza6823 3 місяці тому +4

      It is but the title is wayy over the top

  • @Dad-ij2qy
    @Dad-ij2qy 3 місяці тому +20

    Thank you for describing the pattern-matching and default assumptions so thoroughly and illustrating each point with example code. Until today have never seen any awk tutorial that could get me up to speed so quickly as your video. Kudos!
    Showing how awk can replace both the grep and sed commands was icing on your cake.
    And your last sentence was a big flaming torch sitting atop the cake!

    • @BytebroUK
      @BytebroUK 2 місяці тому

      Get real- once you learn regex, and in my own world, specifically Perl regex, that stuff becomes fairly trivial. "Analysing log files from umpty-hundred jobs" used to be a chore but these days I can script a working solution in an hour or so. In Perl. Because that's the tool I'm familiar with.

  • @BluesManPeich
    @BluesManPeich 7 місяців тому +4

    This is an amazingly instructive video. Thank you.

  • @PauloConstantino167
    @PauloConstantino167 2 роки тому +25

    Dude........ Your content is brilliant. You must become more known! We desperately need more Unix content on youtube.

  • @krozareq
    @krozareq 2 роки тому +20

    @4:10 "As you see, awk is not quite this smart. And here you can see how awk isn't quite as good as a CSV parser. "
    In GNU awk set the built-in FPAT variable. In your example: FPAT = "([^,]+)|(\"[^\"]+\")"

  • @christopherweeks89
    @christopherweeks89 3 місяці тому +5

    This is video is great and demystified awk in a very easy to understand way

  • @Quarky_
    @Quarky_ 3 місяці тому +1

    Amazing presentation! I've been avoiding Awk for close to a decade, so much so I default to Sed for this kind of tasks! After watching your video, I feel more confident to try Awk next time :) Thank you!

  • @stillwrinkled
    @stillwrinkled Рік тому +7

    so much content in just 10mins. amazing!

  • @pneumaticdetach
    @pneumaticdetach 10 місяців тому +2

    Awesome explanation. Thank you

  • @xyve6129
    @xyve6129 3 місяці тому +3

    I always thought awk was super hard to learn. 😭 Thanks for explaining it so well! 🙏

  • @Neura1net
    @Neura1net 3 місяці тому +2

    This was an exceptionally good tutorial. Thank you.

  • @MohamedAli-dk6cb
    @MohamedAli-dk6cb 3 місяці тому +1

    Finally and after so many years, I understand how 'awk' works. Thank you, Legend

  • @pldcanfly
    @pldcanfly Місяць тому

    This is such a great explainer of a tool i rarely used, but saw the potential, although i never dove in deep enough to learn it. Thank you!

  • @robbybankston4238
    @robbybankston4238 3 місяці тому +2

    At my past job where we used Linux exclusively, I used awk extensively along with bash scripts, sed, tr, od, etc. There are so many handy Linux commands.

  • @Zeioth
    @Zeioth 3 місяці тому +70

    "I was so unproductive!" → Proceeds to open the Gnome terminal

    • @GreyDeathVaccine
      @GreyDeathVaccine 3 місяці тому +1

      Alacritty FTW 🙂

    • @lanternofthegreen
      @lanternofthegreen 3 місяці тому +10

      This is why people hate the Linux community.

    • @-aexc-
      @-aexc- 3 місяці тому +1

      using a better terminal does t make you more productive, just pipe the massive prints so you dont have to worry about print speed on compilation or something. (i say this as someone who uses a fast terminal (foot))

  • @RickTimmis
    @RickTimmis 3 місяці тому +1

    Nice Video, this is a great explanation of awk, thank you for sharing.

  • @AWriterWandering
    @AWriterWandering Місяць тому +1

    Awk is a very powerful program indeed. The only thing that keeps it from completely replacing grep for me is the lack of a Perl mode for regex.

  • @leonvolq6179
    @leonvolq6179 10 місяців тому +5

    Before awk I was living on the street and had no significant other.
    With awk I'm now living on a mansion and have two wives 🎉

  • @fanshaw
    @fanshaw 3 місяці тому

    Excellent explanation.

  • @moreirajesse
    @moreirajesse Рік тому +2

    Nice tips and examples, man.
    Greetings from Brazil.

  • @FishKungfu
    @FishKungfu Місяць тому +1

    Great video! So, it's 3 years later, I hope you got your juicy 1% raise!

  • @johnhopkins849
    @johnhopkins849 2 місяці тому +1

    I've never done more with awk than printing columns from a text file, like the 'cut' command. And for other things, use a perl one-liner. Loved the average calculation example in awk. Good to have a new tool in the belt!

  • @multipontushd4626
    @multipontushd4626 3 місяці тому +3

    I used awk and sed to convert entire flight manuals into our dataformat that won us the deal with pilatus as we could convert it to our software suit.

  • @TheEvertw
    @TheEvertw 3 місяці тому +1

    Excellent presentation of how AWK works and how it could benefit you.
    I haven't used it personally (I would use Python: slightly more complex to use, but MUCH more powerful), but I know people who use it often, e.g. to scan log files for certain situations. It is great for iteratively improving the filters, browsing through the data.

  • @chang112x
    @chang112x 3 місяці тому +1

    The awk command is my favorite linux command. 😂😂😂 Great content! Keep going!

  • @hermask815
    @hermask815 3 місяці тому +2

    At a time when Excel had only 65000 lines, I used awk to condense big text data files to a manageable size used the associative array feature of awk.
    If you’re working with same files over again, I suggest to include one sample line for each pattern because you may not recognise the line from the pattern after 2 months.
    The Fahrenheit example I’d done in libreOffice. Import and so on.
    There was a time where you had difficulties getting an awk that works on windows.

  • @plasticdub1477
    @plasticdub1477 2 місяці тому

    agreed - awk is awesome and i use it all the time - the most extreme example was a ~400 line script to analyze network files extracted from big integrated circuits but it’s great (and fast) at processing big text files - and it’s highly portable too since it’s installed on pretty much every unix/linux system dating back to the 1960s

  • @prism223
    @prism223 3 місяці тому +3

    Real world examples IME look something like this:
    Some poorly documented program just spat out a noisy status message and produced a bunch of poorly named files. You want to parse the message to associate metadata with the output files, then rename the files with metadata as part of the name.
    First pipe message into awk to separate into fields, then do simple transform in awk or pipe into sed or grep, then sort file names for association with the metadata output. Then pipe both into awk again to generate a shell script to rename the files.

  • @TheEvertw
    @TheEvertw 3 місяці тому +1

    I love how simple programs developed 50 years ago are still extremely useful.
    That is because the core of Computing hasn't changed much at all over that time, and UNIX did an excellent job of capturing that core.
    I pity the fools who know nothing outside of a GUI. Because with a GUI, you get a single tool that can do only what its designers allow you to do. But the UNIX concept is to have a load of little tools that one can combine to do exactly that what you want it to do.
    Perhaps I should write a GUI overlay for the shell, allowing the old UNIX tools to be configured and linked together graphically. That would be fun, and might help people discover the tools that are available at the CLI.

  • @jozefsoucik3115
    @jozefsoucik3115 3 місяці тому

    I like your shorts "this is my favorite command", but the longer are more explanatory and better pauseable aswell. Thanx

  • @jiangxu3895
    @jiangxu3895 Рік тому +1

    Hello, thanks for sharing this knowledge. Interesting way of presentation and very concise and informative.

  • @zeppelinmexicano
    @zeppelinmexicano 3 місяці тому +20

    The temperature data format is a good one for exercising awk. This is a data driven world.

  • @user-pd1ch1uv8e
    @user-pd1ch1uv8e Рік тому +2

    Great vid thanks! @10:20 the "C" doesn't appear in the output. Should it be inside the double quotes? ie ` C" = "` be `" C = "`?

  • @ravibommareddy7484
    @ravibommareddy7484 2 роки тому +2

    My man ! Thank you

  • @phillipscott1920
    @phillipscott1920 3 роки тому +4

    Super Useful, and entertaining

  • @sanketss84
    @sanketss84 6 місяців тому +1

    super helpful

  • @first-thoughtgiver-of-will2456
    @first-thoughtgiver-of-will2456 3 місяці тому +6

    I really think we need better parsing libraries and at some point the most effective way to dev will be an editor that is easy to add features to which essentially will be coding from the command line. Even between awk and sed there are editing cases where I cannot cleanly implement my operation/macro.

  • @linjunhong2005
    @linjunhong2005 2 роки тому +1

    very nice video .thanks!

  • @takeshikovacs1081
    @takeshikovacs1081 3 місяці тому

    awk is amazing , I love it !

  • @saaah707
    @saaah707 3 місяці тому +2

    Humorous but informative, I'm no longer afraid of awk, nice video
    Don't even ask how many python scripts i wrote to do this kind of stuff, grappling with pandas csv reader and such

  • @panossavvaidis6086
    @panossavvaidis6086 2 місяці тому +1

    BEST INTRO TO AWK. PERIOD!

  • @Blaisem
    @Blaisem 3 місяці тому +1

    I remember when I used to torture myself with arcane bash commands and construct a towering awk command for complex file parsing. The cryptic awk errors were chef's kiss.
    Honestly I just prefer any other language at that point.

  • @Sahuagin
    @Sahuagin 3 місяці тому

    I was hoping there was a "but" to the "doesn't parse quotes" problem. it feels like I would always be running into the issue that I couldn't quite parse a file with 100% accuracy. (some line or other would be inconsistent somewhere.)

  • @doughale1555
    @doughale1555 3 місяці тому +1

    I challenged a guy who believes in awk, I let him define the problem. He could use awk, sed, … and I would use cpp, yacc, and lex. The challenge was on two fronts, dev time - first to start, and run time. He insisted that he may run slower than me, but he would clearly win dev time.
    Well, I ended up not using yacc, just cpp and lex. Beat him in dev time by nearly an hour. Mine ran in less than a second and his took a few minutes.
    To me awk is awkful with a silent K. It is a very useful tool, but it is just so easy to create your own specific, and much better tool quicker than using awkful.

  • @Hizashisam
    @Hizashisam 2 місяці тому +1

    You are the great teacher

  • @coffeedude
    @coffeedude 2 роки тому +1

    Great channel

  • @bromophenol2469
    @bromophenol2469 3 місяці тому +2

    The awk command is my favorite command.

  • @familyshare3724
    @familyshare3724 3 місяці тому +2

    Awk is great, but not the only hammer for every nail. Sed, cut, bc, (node maybe), vim macro, bash, lots of ways to solve this with one line or so

  • @DougDingus
    @DougDingus 3 місяці тому

    I love this video. Awk is one of the basic UNIX tools I always skipped over.
    Bad call, lol.

  • @yehudahecht1520
    @yehudahecht1520 2 роки тому +1

    Question. In your initial use case, why is awk preferred over sed?

    • @RobertElderSoftware
      @RobertElderSoftware  2 роки тому +6

      'sed' is generally preferable in situations where the text changes you want to make can be described by a regular expression. 'awk' is preferable in situations where the changes you want to make require more arbitrary computation that can't be described by a regular expression (such as a mathematical calculation). If you want to try and precisely describe the class of problems that each tool solves, you could probably draw a relationship to the Chomsky hierarchy:
      en.wikipedia.org/wiki/Chomsky_hierarchy
      However, describing the difference this way is a bit of an oversimplification that would be a good of starting arguments among computer scientists.

  • @lifewater
    @lifewater 2 місяці тому +1

    Ah the classic 10x engineer,
    Making 10x the work for everyone else. I too have earned this little.

  • @dumitrus.6925
    @dumitrus.6925 2 роки тому +5

    I enjoyed your presentation on awk and I subscribed to this channel. I have a question: Can awk to the following job -- send the first line of a file1, delimited by default space, to another file2, file2 that would take its name from the first few fields of the line 1 just transferred from the file1? Thank you.

    • @RobertElderSoftware
      @RobertElderSoftware  2 роки тому +5

      Given a file 'a.csv' with contents:
      field1 field2 field3
      a b c
      d e f
      g h i
      You can do
      awk -F' ' 'NR==1{print $0 > $1"_"$2".csv";}' a.csv
      which produces this file:
      field1_field2.csv
      with contents:
      field1 field2 field3
      OR what you maybe also wanted to do:
      is this:
      awk -F' ' 'NR==1{fname=$1"_"$2".csv";}NR>1{print $0 > fname;}' a.csv
      which produces a file named:
      field1_field2.csv
      with these contents:
      a b c
      d e f
      g h i
      I just did this on my machine using GNU awk. Not sure if that'll work the same in all POSIX awk implementations though.

    • @dumitrus.6925
      @dumitrus.6925 2 роки тому +2

      @@RobertElderSoftware Super! Thank you. I used based on your awk: awk -F' ' '{fname=$1" "$2;}NR>0{print $0 > fname;}' file

  • @aGj2fiebP3ekso7wQpnd1Lhd
    @aGj2fiebP3ekso7wQpnd1Lhd 3 місяці тому +1

    Writing a dedicated program would have taken about 7 lines of code and 5 min, not forever. But, I digress. Us Nix folks live by grep, sed, awk, cut, xargs, etc.

  • @nukebarbarbarian3735
    @nukebarbarbarian3735 2 роки тому

    Thank you for saving my life!

  • @Trazaeth
    @Trazaeth Місяць тому

    I use awk over grep daily because of it's usefulness in creating conversions or finding ways of pattern matching smartly. It's grep and cut in one. The only time i use cut is for specific columns due field separators being a pain sometimes.

  • @Mr_Jombles
    @Mr_Jombles Рік тому +1

    Dude, this video was sick! Looovely stuff. You're awesome: 👑

  • @sabitkondakc9147
    @sabitkondakc9147 Рік тому +1

    yep, awk changed my habits either, thanks for sharing!

  • @lldadb664
    @lldadb664 3 місяці тому +1

    It's been 3 years since you posted the video. I hope you got that raise. Gotta offset inflation somehow.

  • @generalzugs6017
    @generalzugs6017 3 місяці тому +1

    Hmm, first time I watched this video, sound was behind the image, so you looked like Bruce Lee speaking in movies 😁 I thought it was intentional at first, then realized it was a problem in my browser. AWKward.

  • @Wilhuf1
    @Wilhuf1 3 місяці тому

    But, how would you use awk to handle csvs?

  • @ziranshuzhang6831
    @ziranshuzhang6831 3 місяці тому +4

    writing a dedicated program takes forever? I agree awk does faster, but writing a python script will take at most half a minute...

  • @starterdev
    @starterdev 3 місяці тому +2

    I'll never use IDEs and Vscode anymore to process texts!
    Thanks ❤

  • @bultvidxxxix9973
    @bultvidxxxix9973 3 місяці тому

    For reference, here is a PowerShell solution for that problem:
    Import-Csv .\temps.csv -Delimiter "`t" | Select-Object @{Name="temp";Expression={if($_.unit -eq "F") {"$([math]::Round(($_.temp-32)/1.8,1))"} else {$_.temp}}}, @{Name="unit";Expression={"C"}} | ConvertTo-Csv -Delimiter "`t" -NoTypeInformation | %{$_.toString().Replace("`"", "")}
    However normally you wouldn't do that as one line in PowerShell. You can just save the whole table as a variable and work on that instead:
    $temps = Import-Csv .\temps.csv -Delimiter "`t"
    foreach($entry in $temps) {if($entry.unit -eq "F") { $entry.unit="C"; $entry.temp="$([math]::Round(($entry.temp-32)/1.8,1))" }}
    $temps | ConvertTo-Csv -Delimiter "`t" -NoTypeInformation | %{$_.toString().Replace("`"", "")}
    Assuming you need it in exactly the same format again. I'd argue that using commas in a csv file and quoting the values would be better though.

  • @rafajanicki2456
    @rafajanicki2456 3 роки тому +15

    A question.
    If awk makes me 10x engineer and let's say grep makes me 3x engineer - does it mean output from this pipe:
    $ awk {print $1} somefile.txt | grep somepattern
    makes me 30x engineer? :P

    • @RobertElderSoftware
      @RobertElderSoftware  3 роки тому +9

      I think you're really onto something here.

    • @eadweard.
      @eadweard. 2 роки тому +1

      Unbearable.

    • @andreipopescu7636
      @andreipopescu7636 2 роки тому +5

      Don't waste available tools: cat into awk!

    • @beginlinuxguru7354
      @beginlinuxguru7354 4 місяці тому +3

      @@andreipopescu7636 That's cat abuse. As a long-time guardian of cats, that bothers me.

  • @BooleanOperator
    @BooleanOperator 3 місяці тому +3

    Great presentation style. I just subscribed, hoping to hear if you got that 1% raise.

    • @RobertElderSoftware
      @RobertElderSoftware  3 місяці тому +1

      I didn't get any raise this year, but I've got a good feeling that if I work overtime for just a couple more years, someone will finally notice my hard work :)

  • @NizarAjeebi
    @NizarAjeebi 2 роки тому +1

    Quick question:
    @ 2:03 You added " ? " and " : " inside the condition parentheses.
    Can you please explain what the question mark " ? " and the colon " : " are used for?

    • @RobertElderSoftware
      @RobertElderSoftware  2 роки тому +4

      The '?' and ':' symbols are part of a feature that is available in most programming languages for doing in-line conditional assignments. It's usually called a 'ternary operator'. Here is some awk-specific documentation on this feature: www.gnu.org/software/gawk/manual/html_node/Conditional-Exp.html

    • @NizarAjeebi
      @NizarAjeebi 2 роки тому

      @@RobertElderSoftware Oh.. now I understand. It is just like this... ( ? : )

    • @FaranAiki
      @FaranAiki 2 роки тому +1

      ​ @Nizar, yes, you are right. However, most programming language do not support the "if-condition-is-true" as an equation. For example, maybe it is illegal to do "isLoli? legal = false : legal = true".

    • @krozareq
      @krozareq 2 роки тому

      @@NizarAjeebi Yep. From 'man gawk': "?: The C conditional expression. This has the form expr1 ? expr2 : expr3. If expr1 is true, the value of the expression is expr2, otherwise it is expr3. Only one of expr2 and expr3 is evaluated"

  • @i.8530
    @i.8530 2 місяці тому +1

    Its now 3 years later, he better have gotten that 1% raise

  • @kjyu4539
    @kjyu4539 10 місяців тому +1

    thank u

  • @M.W.777
    @M.W.777 3 місяці тому +1

    Thanks -- You have a new Sub!! Take care

  • @TecnocraciaLTDA
    @TecnocraciaLTDA 3 місяці тому

    Today AWK isn't only a text-processing utility, it is a complete general purpose programming language! You can use loops, variables, regex, conditionals, functions, array and string manipulation, math lib, include files...

  • @Misteribel
    @Misteribel 3 місяці тому +5

    Writing a script in C#, F# or Python to do this takes 1 minute and the code will be more understandable and can be copied into your project. Awk is Awesome in niche situations, but I'd only use it when other languages are not available.

    • @andrefig822
      @andrefig822 3 місяці тому +1

      yeah given this is just a backstory case for a awk lesson.
      It still really depends the tech the dev is more used to. If the peson uses shell commands a lot everyday, it's easy to just awk, great to use what it offers. Otherwise is just no-brainer to write a small standalone app/script in your fav language (or any tech), hell it's most of the times just easier to google spreadseet or prompt into ai assistant (that appeared after this video being posted)

  • @rehanga6944
    @rehanga6944 3 місяці тому

    How about using Excel or Libre Office instead to open the csv file?

    • @paulsutherland3813
      @paulsutherland3813 3 місяці тому

      For just viewing a more complex csv, sure, but the transformations (especially more complex ones) are better scripted.
      Libreoffice beats Excel for me with imports as it defaults to UTF.

  • @bestsoundeffectsyt
    @bestsoundeffectsyt 3 місяці тому

    nice video haha. hope you make more

  • @OneManCanStopTheMotorOfWorld
    @OneManCanStopTheMotorOfWorld 3 місяці тому +2

    The Awk command is my favorite Linux command

  • @jcdenton7914
    @jcdenton7914 3 місяці тому

    It's 3 years later, did you get that raise bro?

  • @elginbeloy9066
    @elginbeloy9066 2 місяці тому

    0:30 dedicated Python code for that task is 6 lines.
    ``python
    with open('temps.txt', 'r') as input_file:
    with open('temps_all_c.txt', 'w') as output_file:
    temp, scale = line.strip().split()
    if scale == 'F':
    temp = (float(temp) - 32) * 5/9
    out_file.write(f'{temp} C
    ')
    ```

  • @skyeplus
    @skyeplus 3 місяці тому

    There is also jq for json manipulation, but I've never used it in practice.

  • @dylanh333
    @dylanh333 2 місяці тому

    If you're working in a Windows environment, you can use PowerShell in much the same way for data processing tasks like this.
    That said, I really need to start using awk in Linux instead of just contorting sed into doing things it wasn't made to do.

  • @dexterplameras3249
    @dexterplameras3249 3 місяці тому +1

    Perl was written because Larry Wall was frustrated with the Awk+Sed combo. Awk+Sed didn't do what he wanted it to do. Perl is still much better then the Awk+Sed combo, however very few people learn Perl but have reverted to learning Awk+Sed instead for text processing. Its a real shame because Perl is still hands down the best for text processing, whether it be on the command line or processing text files.

  • @alexonrails
    @alexonrails 3 місяці тому

    in 2024 it's counter-productive to rely on awk as it's missing libraries to work with common formats: multiline rows, binary (like parquet), csv with quotes, headers, footers, excel
    i.e. pandas.read_csv in jupyter/ipython would do the same (could have a one-liner if you wish) but it's compatible with binary formats and anything you could possibly think of.
    another option is excel if there is no need to repeat the transformation.

  • @DarrylHebbes
    @DarrylHebbes 3 місяці тому +1

    I tried awk as well but only managed to be a 3x developer, how do I get the extra 7x?

    • @charlesabju907
      @charlesabju907 3 місяці тому

      Its multiplicative I guess. So the question would be where he got the extra 3.33x

  • @giuseppefaieta8620
    @giuseppefaieta8620 2 роки тому

    Hi, thanks for this useful video. Can you kindly explain what is the "%c
    " modifier doing on the printf command ? thanks!

    • @RobertElderSoftware
      @RobertElderSoftware  2 роки тому +2

      '%c' is a pretty common format specifier for 'printf' functions, although after looking into this specifically for awk, I don't think '%c' is officially supported by awk. Therefore, this is probably a non-standard feature and should therefore be avoided. Here is a general wikipedia article on printf format specifiers for C programming:
      en.wikipedia.org/wiki/Printf_format_string#Type_field

  • @pascalcoole2725
    @pascalcoole2725 3 місяці тому

    I started to use perl for most of those kinda things years ago.
    But indeed AWK is a usefull tool.
    Beside stuff like AWK, SED or PERL differs you from the dotNot kiddies.

  • @yoitsgiook
    @yoitsgiook Рік тому +2

    1% raise 😂
    Thanks for the tutorial!

  • @essetee
    @essetee 3 місяці тому

    Here we work to live, we don't live to work. Social life is more important than work.

  • @hansdampf2284
    @hansdampf2284 2 місяці тому

    0:10 before I read about the emacs command I was a very productive employee. My boss would assign me a task and I would just do it.
    Then I read about emacs and now my boss assigns me a task and I spent half a day configuring emacs and another half to write something in emacs that gets the job done

  • @e74av
    @e74av 3 місяці тому

    1.5% raise for the gentleman please.

  • @test-rj2vl
    @test-rj2vl 3 місяці тому +1

    When I look at the command you ended up with I think if it was me it would have taken me less time to write it in python that I already know than to learn all that in awk.