I am using sed command make substitution in the file. Assume my file1 is:  10 11 10 11   Then I want to substitute the 1st "10" in file1 to "12", and dump to file2. The file2 should be:  12 11 10 11   I tried this command:  sed 's/10/12/' file1 &gt;file2   But it changed the 2nd "10" also. So, how can I write the sed command to do that?
I would like to update a large number of C++ source files with an extra include directive before any existing #includes. For this sort of task, I normally use a small bash script with sed to re-write the file.   How do I get sed to replace just the first occurrence of a string in a file rather than replacing every occurrence?  If I use  sed s/#include/#include "newfile.h"\n#include/   it replaces all #includes.   Alternative suggestions to achieve the same thing are also welcome.
Why is my variable unaltered after I modify it inside of a function? - Asynchronous code reference No space following macro without argument With a macro such as:  \def\naive{na\"{\i}ve}   I find that the space which I would hope to follow it, is absent. So, with  the \naive approach   I get     the naïveapproach   in the output. How do I bring back the space? Regression with only categorical variables Get text between two strings Regex VB.Net Exec format error of gcc-compiled Hello World c++ On AWS Ubuntu Server, I wrote C++ Hello, World program:  #include &lt;iostream&gt; using namespace std;  int main(){         cout&lt;&lt;"Hello, World!"&lt;&lt;endl;         return 0; }   And compiled it:  ubuntu@ip-xxxxx:~/dev/c++$ g++ -c ./test.cc -o out ubuntu@ip-xxxxx:~/dev/c++$ chmod a+x out ubuntu@ip-xxxxx:~/dev/c++$ ./out -bash: ./out: cannot execute binary file: Exec format error ubuntu@ip-xxxxx:~/dev/c++$ file ./out ./out: ELF 64-bit LSB  relocatable, x86-64, version 1 (SYSV), not stripped ubuntu@ip-xxxxx:~/dev/c++$ uname -a Linux ip-xxxxx 3.13.0-48-generic #80-Ubuntu SMP Thu Mar 12 11:16:15 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux ubuntu@ip-xxxxx:~/dev/c++$ gcc --version gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4   It seems that architecture x86-64 is the same each other. What is the problem here? Do I have to add more C++ flags? Why are angles dimensionless and quantities such as length not? So my friend asked me why angles are dimensionless, to which I replied that it's because they can be expressed as the ratio of two quantities -- lengths.   Ok so far, so good.  Then came the question: "In that sense even length is a ratio. Of length of given thing by length of 1 metre. So are lengths dimensionless?".   This confused me a bit, I didn't really have a good answer to give to that. His argument certainly seems to be valid, although I'm pretty sure I'm missing something crucial here. How to make a figure span on two columns in a scientific paper? Why is the installer not showing any partitions? I'm having a problem installing Ubuntu, and Kali as well. I downloaded the iso from the official site &amp; tried installing using USB. I also tried desktop installation, but the problem is same.  It shows a single drive i.e. my total Hard Disk and if I select it, it asks me to create a new partition &amp; shows total space as FREE.  It's with all Ubuntu I downloaded, 11.10 Server, 12.10 and 13.04. I also tried to install BackTrack's new version Kali Linux but again I got the same problem.  I hope I meet thier system requirements. Here's my system details for your ease:   OS: Windows 7 Ultimate Processor: Intel P4 2.80 GHz RAM: 3GB Hard Disk: 320GB No of Local Drives: 4 (1 Primary, 3 Logical) Free Space: 195GB (about) Motherboard: G31 Cache: 1MB Help me, please. $127$ has an interesting property: It is the $31$st prime number and its rank ($31$) is also a prime. $31$ is the $11$th prime so its rank is also a prime. $11$ is also a prime number with a rank ($5$) that is also a prime. $5$ is the 3rd prime number and and so its rank ($3$) is also a prime. And finally $3$ is the $2$nd prime so its rank is also a prime... Is there a name for primes whose rank (index in the prime series) is also a prime? That is:     If $a_i$ is the $i$th prime number, then $i$ is a also a prime.   How about numbers like $127$ where going down ranks of ranks always produce prime numbers (down to rank $2$ of course)? The first $11$ :-) primes in this (infinite) series would be:  $3, 5, 11, 31, 127, 709, 5381, 52711, 648391, 9737333, 174440041, \dotsc$  Many thanks! Say you have a stick which breaks randomly into three pieces (we can choose the points randomly). What is the probability that the area is greater than or equal to $0.4$?   I can see it has something to do with Heron's formula but I just can't put t together. I want to run DFS replication between a couple of servers. It's my understanding that the servers need to be part of a domain for this. Being able to give people a username and password that works on all servers would be useful too, so I can lock up the admin password.  All machines will be running Windows 2008R2 and they will all be running Windows Firewall, so I need to be able to allow the other machines to connect to this server, but lock out everyone else.   So my question is: what ports do I need to allow the machines to connect to the Domain Controller over? plist or sqlite Two-Weapon Fighting & Bonus Actions Is there any online resource that can tell me what visa rules are for passport holders of a specific country? When thinking about travelling, I often have to think about a place to visit, and then look up visa rules for that particular country. This can be a fairly painful process because official government sites can often be hard to find, and advice on (say) guidebooks or Wikitravel tends to be generic.  Is there any resource where I can enter my nationality/residency, and then look up a list of visa rules for various countries? Allow a user to download a file after submitting their email address How old should you be when you begin Jedi training? Minimal polynomial of $\sqrt{2}+\sqrt{3}$ over $\mathbb Q$ I had an example in the book given as follows:        Find the minimal polynomial of $\sqrt{2}+\sqrt{3}$ over $\mathbb Q$ .       Solution:  $~~~~~$$(\sqrt{2}+\sqrt{3})^2=5+2 \sqrt6$      $(\sqrt{2}+\sqrt{3})^4=49+20 \sqrt6$       Then $(\sqrt{2}+\sqrt{3})^4-10(\sqrt{2}+\sqrt{3})^2+1=0.$       Thus $a=\sqrt{2}+\sqrt{3}$ satisfies $f(x)=x^4-10x^2+1$ over $\mathbb Q$.       Let $p(x)$ be the minimal polynomial of $\sqrt{2}+\sqrt{3}$ over $\mathbb Q$.Then $(\sqrt{2}-\sqrt{3}),(-\sqrt{2}+\sqrt{3}),(-\sqrt{2}-\sqrt{3})$ are also roots of $p(x).$   So degree of $p(x)$ is atleast $4$.      But $f(a)=0 $ and $f(x) \in \mathbb Q[x] \implies p(x)$ divides $f(x)$ .      So $f(x)$ is minimal polynomial of $\sqrt{2}+\sqrt{3}.$   But I can't get the step  how are $(\sqrt{2}-\sqrt{3}),(-\sqrt{2}+\sqrt{3}),(-\sqrt{2}-\sqrt{3})$ also roots of $p(x).$   Kindly help with this. If you select "USB" and "Mac" on , it gives a series of command line instructions to make a USB key which the MacBook will boot into Ubuntu from.  I've followed them to the letter two or three times on different USB keys, and it doesn't work. There's a very great deal of technical discussion about EFI etc. but this set of instructions seems to suggest it should just work, but it doesn't.  Help? I'm increasingly unhappy with the more locked-down approach Apple is taking, and I'd quite like to start using Linux with a view to transitioning over to using it as my main operating system, but booting from the CD takes forever, runs slowly and I'm really hoping to get it moving off USB.  Can anybody help me? I want to make it so I always have 50 entities in an area. So when 1 dies/despawns/leaves the area I want it to detect that and summon in a new entity, and yes I do want them to die/despawn/leave the area so preventing those things is not an option. 2 different passports with different surnames