Syntax error near unexpected token `('

I am new to scripting in ubuntu.

FOR /F "tokens=2 skip=4" %%G IN ('svn info --revision HEAD') DO... 

I get the following error: "Syntax error near unexpected token" ("". Can someone tell me why I get this error?

+4
source share
2 answers

So basically what you are trying to do is

  • Iterate through strings printed by svn info --revision HEAD
  • From line 5
  • Assignment of the 2nd element / field / column to the variable %%G

One of the many ways to do this in Bash is

 for variable in $(svn info --revision HEAD | awk 'NR>4 {print $2}'); do ... something fun ... done 

What does it mean is

  • You send / "send" the output of the svn info --revision HEAD to awk .
  • If NR (the number of processed records / rows) is greater than 4 (i.e., skips the first 4 rows), awk displays the 2nd column / field / element.
  • Then all $(..) is replaced by awk , something like

     item2_line5 item3_line6 item2_line7 .... 
  • Due to the separation of the words Bash, each line is considered as an element in the list, and for iterates through each element in the list.

+3
source

Your team is a Windows team. See the Windows FOR documentation here .

If you work in Ubuntu, enter man for in the terminal and you will get documentation.

+1
source

Source: https://habr.com/ru/post/1443164/


All Articles