i have recently learned how can i use curly braces to run multiple commands using curly braces for example, i can create 10 files like this,  touch {1..10}.txt   or file with odd names,  touch {1..10..2}   I can also restart multiple process like,  systemctl restart app9-{server,client,test}   above command will restart services called, app9-server , app9-client and app9-test  now i have a command with a space in it,  vagrant destroy app9 vagrant up app9 vagrant ssh app9   how can i run above 3 commands using braces?  I tried,  vagrant {destroy app9,up app9,ssh app9}   and  vagrant {destroy,up,ssh} app9   but none of them actually works.  Can someone please tell me how can i run these commands using braces?
120770
The output of the above command when passed through echo is:  # echo systemctl\ {restart,status}\ sshd\; systemctl restart sshd; systemctl status sshd;   Even if I paste the output to the terminal, the command works. But when I try to directly run the command, I get:  # systemctl\ {restart,status}\ sshd\; bash: systemctl restart sshd;: command not found...   I have two questions..   What exactly is this method of substitution and expansion called? (So that I can research it and learn more about it and how to use it properly).  What did I do wrong here? Why doesn't it work?
24737
Lets say I have a loop in Bash:  for foo in `some-command` do    do-something $foo done   do-something is cpu bound and I have a nice shiny 4 core processor. I'd like to be able to run up to 4 do-something's at once.  The naive approach seems to be:  for foo in `some-command` do    do-something $foo &amp; done   This will run all do-somethings at once, but there are a couple downsides, mainly that do-something may also have some significant I/O which performing all at once might slow down a bit. The other problem is that this code block returns immediately, so no way to do other work when all the do-somethings are finished.  How would you write this loop so there are always X do-somethings running at once?
21443
Is there any standard that covers the portability of running a command after variable assignment on the same line?  APPLE="cider" echo hi   How portable is something like that? Where will it work and where won't it?   Also: my shell scripts start with #!/bin/sh if that makes any difference.
4093
Why does everyone tell me writing code like this is a bad practice?  if (foo)     Bar();  //or  for(int i = 0 i &lt; count; i++)     Bar(i);   My biggest argument for omitting the curly braces is that it can sometimes be twice as many lines with them. For example, here is some code to paint a glow effect for a label in C#.  using (Brush br = new SolidBrush(Color.FromArgb(15, GlowColor))) {     for (int x = 0; x &lt;= GlowAmount; x++)     {         for (int y = 0; y &lt;= GlowAmount; y++)         {             g.DrawString(Text, this.Font, br, new Point(IconOffset + x, y));         }      }  }  //versus using (Brush br = new SolidBrush(Color.FromArgb(15, GlowColor)))     for (int x = 0; x &lt;= GlowAmount; x++)         for (int y = 0; y &lt;= GlowAmount; y++)             g.DrawString(Text, this.Font, br, new Point(IconOffset + x, y));   You can also get the added benefit of chaining usings together without having to indent a million times.  using (Graphics g = Graphics.FromImage(bmp)) {     using (Brush brush = new SolidBrush(backgroundColor))     {         using (Pen pen = new Pen(Color.FromArgb(penColor)))         {             //do lots of work         }     }  } //versus using (Graphics g = Graphics.FromImage(bmp)) using (Brush brush = new SolidBrush(backgroundColor)) using (Pen pen = new Pen(Color.FromArgb(penColor))) {     //do lots of work }     The most common argument for curly braces revolves around maintance programming, and the problems that would ensue by inserting code between the original if statement and its intended result:  if (foo)     Bar();     Biz();     Questions:   Is it wrong to want to use the more compact syntax which the language offers? The people that design these languages are smart, I can't imagine they would put a feature which is always bad to use. Should we or Shouldn't we write code so the lowest common denominator can understand and have no problems working with it?  Is there another argument that I'm missing?
69390
Could someone explain to me the difference between &gt; and &gt;&gt; when using shell commands?  Example:  ps -aux &gt; log ps -aux &gt;&gt; log   It seems the result is the same either way.
92716
Can anyone tell me about the -t option when invoking bash?   I found the following  handy command to use a    urxvt -geometry 80x3 -name 'bashrun' -e sh -c "/bin/bash -i -t"   Through a little investigation of its behavior, I see that the -t essentially makes bash exit after executing one command, but I am curious if there is any more to that specific -t option. I can't actually find any documentation about it, and I've looked through the following docs:   man bash     I find it odd that -t is not as clearly laid out as the rest of the options.
47782
I am trying out the command  $ b=5; echo `$b`; -bash: 5: command not found   but it does not print 5 as it is supposed to. What am I missing here?   seems to say that ` evaluates the commands within and replaces them with the output.
84795
Do not run this command to 'test' it unless you are prepared for a crash and/or force-rebooting your system.  I was in my Virtualbox running 12.04 trying to compile an app, and while waiting I happened to chance upon a forum where a comment said:   Try :(){ :|: &amp; };:  Fun, too, and doesn't need root.  Without thinking, I ran it in my gnome-terminal. It made my 12.04(in Virtualbox) lag so badly, I had to shut it down. My question is what does this command do?   :(){ :|: &amp; };:
53822
I have a command, let say php process.php. I want to run 1000 instance of this command to test load caused on the server. How can I do this?  Things to note:   Ctrl+C should terminate all instance at once It is going to run on a single core processor so no need of advance feature like multi-threading. Nice to show current number of running instance on top Commands should output in the same terminal Commands requires no input
69323
I have the following commands that I want to have them all in one shell file:  su – s3 lizinfo.sh –b   when the first linex executes, it prompts and the command prompt become like as below:   -bash-3.1$ (here I cant type second command &gt;&gt; lizinfo.sh –b)   I want to have my shell file run all of these command at once. But when I run my shell file it only runs the first line and for does not run the second line, and waits until I enter it manually.  Would you help me please ?
64001
The find command seems to differ from other Unix commands.  Why is there the empty curly brackets and a backward flash at the end of the following command?  find * -perm 777 -exec chmod 770 {} \;   I found one reason for the curly brackets but not for the backward flash.   The curly brackets are apparently for the path     Same as -exec, except that ``{}'' is   replaced with as many pathnames as   possible for each invocation of   utility
87241
For some processes I use, I almost always run them as background processes by indicating that with "&amp;" at the end. Is there a way to make this standard? Would it be possible to use the alias command in the .bashrc file to do this?
60817
One of my favorite Unix tricks is ^x^y, which will take the last command and replace the first instance of "x" with "y". However, I'm wondering if a similar trick works to replace all instances of "x" with "y" in the last command?
29570
I was curious how I would go about running multiple commands via shell script.  For example, just to try it out, I'd like to be able to connect a .desktop to a .sh that will run all the update codes so I don't have to type it out. I know how to execute a single command via a .sh, not multiple.  Any way?
8288
I want to start using the terminal more often, but I don't know what are the different commands available to me. Is there a way to list all the different commands that I can make use of?
15751
I saw the following syntax in a bash script:   &gt;$(command) &amp;   I know that the ampersand &amp; at the end makes a command run in the background, but I have never seen it in combination with the dollar sign plus the brackets around the command.  What does it do?
76072
In my terminal prompt definition in my .bashrc file, among other things, I have this snippet of code:  ${debian_chroot:+($debian_chroot)}   What does this do, and do I need it?