Outils pour utilisateurs

Outils du site


issue82:command_and_conquer

Ceci est une ancienne révision du document !


Last month, I wrote an article on using regular expressions within Sed, in an attempt to show my process when creating such expressions. Just before writing this month's article, I received an email from a reader, who shared his solution to the problem (formatting a TaskWarrior file). His solution consisted of using a single Sed statement, and addressing lines of the file specifically. His sed command is shown in the box above right.

His explanation: • Take care of this one special case with the title line. As there is an address label (1), this substitution is done only for line 1. In sed scripts, a line number matches only that line. I used an address label only for performance purposes - there would be just one single line matching “^ID”, • Another address label (2). This rule is used only for line 2, and the command is branch (“goto”). As there is no label, it means “goto to the end of the script” - simply skip line 2. This is extraneous for the sake of an example. • The third line matches only the “tasks” line. • The fourth line takes care of the semicolons after the dates, as there will never be two spaces due to right-adjustment. Note that you can also use delimiters other than slashes. • Finally, take care of the rest. Substitute each at-least-two space combinations with a semicolon and the spaces found. This also applies to the first line (headline).

His solution is certainly more efficient than mine, and is a brilliant example of how there are many solutions to these sorts of problems.

Due to the fact that work has kept me extremely busy the last few weeks, I have decided to not write a typical article for this month. Instead, I'd like to run a vote on what article the readers would like to see in FCM#84. The reason why it will appear only in FCM#84, is due to the time frame between FCM being released, and my next article being due. The choices are as follows: • A reader has requested an in-depth article on installing & setting up Rails 4.0.2 on Ubuntu (Ruby on Rails) • I recently installed ArchLinux to an external hard drive, capable of running on UEFI systems (Windows 8 or Mac OS X machines, mainly) • Last month I also offered to set up an article with formatting problems to be solved using regular expressions and sed.

Naturally, anyone who has a preferred topic not listed above, is welcome to mark the “other” box, and to give me a brief description. Anyone is also welcome to input their email address in the form, so that I can contact you with questions about your response. I promise I won't contact you for any other reason. There is also a secondary paragraph text box where you can expand upon your idea.

The link to the form: https://docs.google.com/forms/d/1ZqLOwpwZ-iGkU-LVBDkz65pvO8FK65rIF_X2DWGPLmQ/viewform

I apologize for not having a complete article for you this month. However, FCM#83 should contain a normal article next month.

issue82/command_and_conquer.1402230161.txt.gz · Dernière modification : 2014/06/08 14:22 de auntiee