im quit new to bash and im trying to do a for loop to find all tags not converted to svn in my git directory.
I've run the following command :
echo < for t in $(git for-each-ref --format='%(refname:short)' refs/remotes/tags); do git tag ${t/tags\//} $t && git branch -D -r $t done
However, i've got this error :
-bash: syntax error near unexpected token `&&'
i tryed several things like moving the semicolon but its always the same error but with differents characters like &&, done or i have the following error :
-bash: for: No such file or directory
because those are unix commands, i work on cygwin on windows.
Any ideas ?
ps: Im following this tuto : https://www.gitkraken.com/blog/migrating-git-svn ! thank you for your help :)
CodePudding user response:
<
is input redirection. To it's right, a file name is expected (or a process specification, which then must be enclosed in parenthesis). In your case, you write the word for
to the right of <
and with it ask bash to use a file named for
to replace stdin.
Furthermore, input redirection does not make sense with echo
anyway, because echo
does not process stdin. You are permitted to write a
echo <abc
if you want, but bash will only check the existence of the file abc
and set up the redirection, and echo
will silently ignore it, so there is no purpose in doing this.
CodePudding user response:
First, you are missing a ;
before done
.
Second, you cannot do echo < for t in...
, if you want it to run, remove echo <
.
You will get ambiguous redirects if you don't.