1

I am trying to run the following multiple commands a command prompt but I get syntax error near unexpected token '}'. The following page examples where it is working but I am getting the syntax error. I am running Ubuntu desktop 18.04.5. What am I missing? Thanks.

{echo "Today's date and time"; date;} > f1
user2220115
  • 313
  • 1
  • 2
  • 6

2 Answers2

2

You need a space after the {. The shell needs to see the { as a single token ("words"), but what it sees is {echo so when it gets to the final }, it doesn't know what to do with it:

{ echo "Today's date and time"; date;} > f1
terdon
  • 234,489
  • 66
  • 447
  • 667
1

Insert a space at the beginning :

 { echo "Today's date and time"; date;}
Frédéric Loyer
  • 2,543
  • 4
  • 12