Given: sed -e '/pattern1/,/pattern2/!d' file.org  How can I match the first occurrence of the lines between pattern1 and pattern2, but not the rest?  For example:  pattern1 aaaa pattern2 pattern1 bbb pattern   should output: aaa  Alternatives solutions (using grep, awk or whatever) are welcomed.
How can I select first occurrence between two patterns including them. Preferably using sed or awk.  I have:  text something P1 something content1 content2 something P2 something text something P1 something content3 content4 something P2 something text   I want the first occurrence of the lines between P1 and P2 (including P1 line and P2 line):  something P1 something content1 content2 something P2 something
How to convert an array into comma separated strings in smarty template? Is there any difference between "offense" and "offence"? Take a sponge ball and compress it. The net force acting on the body is zero and the body isn't displaced.  So can we conclude that there is no work done on the ball? jQuery Galleria 'fatal error: no theme found.' in IE What is the preferred way to remove spaces from a string in C++? I could loop through all the characters and build a new string, but is there a better way? How to prove that the set of rational numbers are countable? Can any one tell me how to prove that the set of rational numbers are countable? Prove give me a prove?  Thanks. Should confidence intervals for linear regression coefficients be based on the normal or $t$ distribution? How to disable javascript modal popup ads This question is related to "The Last Jedi":  The maneuvre that vice admiral Holdo (with the purple hair) uses towards the end of the film seems remarkably effective.   It seems that it would have worked pretty well much earlier. Especially as two other ships were just allowed to run out of fuel and be destroyed.  It seems doing it earlier with different assets would have incurred less losses. Yet nobody seemed to consider it. Any in universe reason why? How to efficiently count the number of keys/properties of an object in JavaScript? What's the fastest way to count the number of keys/properties of an object?  It it possible to do this without iterating over the object?  i.e. without doing  var count = 0; for (k in myobj) if (myobj.hasOwnProperty(k)) count++;   (Firefox did provide a magic __count__ property, but this was removed somewhere around version 4.) How to add CSS and JS files on node pages from theme's template.php I am trying to add JavaScript and CSS files to one node type page from my template.php file but it is not working.  Here is my template.php code:   &lt;?php // $Id: template.php,v 1.13 2010/12/14 01:04:27 dries Exp $  function mttheme_preprocess_html(&amp;$variables) {   $node = node_load(arg(1));   if ($node-&gt;type = 'sales_team_page') {     drupal_add_css('misc/jquery.fancybox-1.3.4.css');     drupal_add_js('misc/jquery.mousewheel-3.0.4.pack.js',       array('type' =&gt; 'file', 'scope' =&gt; 'header')     );     drupal_add_js('misc/jquery.fancybox-1.3.4.pack.js',       array('type' =&gt; 'file', 'scope' =&gt; 'header')     );     drupal_add_js('misc/jquery.fancybox-calls.js',       array('type' =&gt; 'file', 'scope' =&gt; 'header')     );   } }   Does anyone know why it is not working? How to find solutions of linear Diophantine ax + by = c? How to draw this P-V graph? When and where was “portfolio career“ first used? The expression  meaning:  the fact of having several part-time jobs at once, rather than one full-time job:    A portfolio career is suitable for people who want to have a variety in their work life.   (Cambridge Dictionary) Etymonline has no information about the origin of the above expression, can anyone tell me when and where it was first used? Is it true that $||a|^p - |b|^p| \le C_p|a - b|^p$ for $1 < p < \infty$? If $a, b \in \mathbb{C}$, then we have the standard triangle inequality for the difference:  $$||a| - |b|| \le |a - b|.$$  I am wondering if this inequality generalizes to exponents greater that one.     My question is, for $1 &lt; p &lt; \infty$, does there exists a constant $C_p$ such that $||a|^p - |b|^p| \le C_p|a - b|^p$ for all $a, b \in \mathbb{C}$?   I am aware of the "standard" triangle inequality for $p &gt; 1$:  $$|a +b|^p \le 2^{p}(|a|^p + |b|^p),$$  and that $2^p$ may not be sharpest constant possible. If I try to use this estimate to prove, say, that $|a|^p - |b|^p \le C_p |a - b|^p$, I get stuck with an extra term that I'm not sure what to do with.  $$|a|^p - |b|^p \le 2^p|a -b|^p + (2^p -1)|b|^p.$$  A resolution on this matter is greatly appreciated. How to easily and completely disable/enable WLAN (so it cannot be turned on again while travelling)? Without going into specifics of why I might like to do this, or whether this is a good idea or not, I would like to know how I can disable use of wireless networking on my MacBook Air, either via removal of software or drivers or similar, such that the machine is unable to connect to a WIFI network in any way without I undo those changes.  The intention is for the machine to be unable to communicate wirelessly when out of the house, and for those changes to not be easily reverted until I return (for example requiring some piece of external storage that does not travel with me and which contains copies of whatever I have removed). How can I easily remove and then re-allow WIFI access (without losing my stored profiles/passwords or disturbing anything else)? Is it possible to simply copy a certain app or plugin to an external drive, delete it from my laptop, and later copy it back, again having everything as it was before?  One year later I have been happily using Daniel Lawson's solution below for quite some time now. I have created two applications with automator, one that deletes the .kext, one that restores it from an USB stick. First, copy /System/Library/Extensions/IO80211Family.kext to a USB stick and leave that stick at home. Open Automator, select to create an &quot;Application&quot;, then choose &quot;Utilities&quot; from the &quot;Library&quot;, then &quot;Execute Shell Script&quot;. (I'm translating this from my German menus, so the exact names may differ.) For the &quot;Disconnector&quot; app, enter the following into the text area of the &quot;Execute Shell Script&quot; event: echo YOUR_ADMIN_PASSWORD | sudo -S rm -rf /System/Library/Extensions/IO80211Family.kext  Replace &quot;YOUR_ADMIN_PASSWORD&quot; by your admin password. Then save the app and drag its icon to the Dock. Now, when you are sure you want to be free of all online distractions, click the app icon, and the IO80211Family.kext is gone. Just restart your laptop and you can no longer connect to WLAN:  For the &quot;Reconnector&quot; app, enter the following into the text area in Automator: echo YOUR_ADMIN_PASSWORD | sudo -S cp -r /Volumes/NAME_OF_YOUR_USB_STICK/IO80211Family.kext /System/Library/Extensions/  Replace &quot;YOUR_ADMIN_PASSWORD&quot; by your admin password and &quot;NAME_OF_YOUR_USB_STICK&quot; by the name of your USB stick. Save the app etc. Now when you return home, insert the USB stick that carries the IO80211Family.kext into your laptop, click the Reconnector app icon and then restart your laptop. Now you can connect to WLAN again. Note. There are some security issues invovled when you echo your admin password, because by that it is written to the shell history and can be found there. I don't care, but you might, depending on your circumstances. Visual Studio "Find" results in "No files were found to look in. Find stopped progress." What's the 'Frequent' sort function? What is the function of the  sorting option on the Questions tab? Added activities, now names and labels and strings aren't registering Android Manifest file Many years ago I read a book or story where a group of people discover a dark city - maybe on another planet - which appears devoid of life but is in very good condition. As they gradually explore the city one of the them falls into a trap and is cut to pieces by something mechanical. This detail I can remember as it was a pretty gruesome idea. I don't know the ending but my guess is that none of them make it out alive.