Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is `ls -al & ; ls -al` invalid?

Tags:

linux

bash

I ran this on my Centos5 box:

ls -al & ; ls -al

I was expecting it to run ls -al in the background, and concurrently run ls -al in the foreground, and demonstrate how the output to terminal gets all mangled by doing so.

However, I get:

-bash: syntax error near unexpected token `;'

How can I write these two commands on the same line?

like image 275
Lightness Races in Orbit Avatar asked Feb 07 '13 14:02

Lightness Races in Orbit


People also ask

Why did Ls get kicked out of C9?

He explains that Cloud9 had built a system for how coaches and the organization work together. He went on to state that LS didn't work within that framework.

Did Ls get fired from C9?

We decided that it was important that we make a change and release LS at that point so we could move forward and focus on the future.” In LS' stead, C9 has promoted Max Waldo to the position of head coach. Waldo spent the 2021 season as an assistant coach on C9's staff.

What does LS stand for League of Legends?

Nick "LS" De Cesare is a League of Legends esports personality, previously head coach for Cloud9. He was previously known as LastShadow.

Why was LS kicked from C9 Reddit?

He was previously a top laner so already his mid lane champ pool is lacking. LS demands for bigger champs pool was too much for him and if he had kept going he would just be behind too much from the other teammates as the season went on.


1 Answers

Unintuitively, & is a command separator as well as a forker. That means you actually have three commands:

  ls -al & ; ls -al
# ^^^^^^^|^|^^^^^^^

... and Bash does not support the empty statement.

Instead, simply write:

  ls -al & ls -al

with no semicolon.

like image 162
Lightness Races in Orbit Avatar answered Oct 18 '22 07:10

Lightness Races in Orbit