![]() ![]() Improved grep with the reset match operator Some people are suggesting interesting alternative solutions. If so, please write your solution in the comments □ If you want to experiment a bit more with this topic, I can propose you a nice variation of this tutorial as exercise:Ĭan you compute the ranking of the nations with the highest number of medals? You will not need to open an editor and write a long script and then to have an interpreter like Node.js to run it, sometimes the command line is just enough you need! If you learn its basic commands and the most common options you will be able to complete a hell of a lot of task directly from the command line by just wisely combining them. I hope this article showed you that the unix shell is a very powerful tool. Lot’s of French people there, uh! It’s a shame no Italian athlete is there yet! □ Conclusion ![]() If we execute it, we can finally discover who are the best Judo Olympic athletes up to Rio 2016: Now that you understood every single part it shouldn’t look very cryptic. So we can easily assume that all the athletes listed in the page are interesting for us.Īs you can see every athlete is referenced in the code using the template flagIOCmedalist and every entry looks like:Ĭurl -sS "" | \ grep -Eoi "flagIOCmedalist\|\\]" | \ cut -c "19-" | \ cut -d \ ] -f 1 | \ cut -d \ | -f 2 | \ sort | \ uniq -c | \ sort -nr The dataset shown before is just the wikitext code needed to render the tables of athletes that won medals by category and year. Pipes let you use the output of a program as the input of another one, effectively creating a stream of data that is transformed step by step by small and easy to understand operations. We will do so with a combination of bash commands, bound together using the pipe operator ( |).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |