I am working with SVN for version control, and whenever I'm ready to commit some changes, I have to stage them all with the following command:

svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add

As you can see, it's quite complicated and I therefore went looking into making an alias for this command.

When opening ~/.bash_profile, I added the following line:

alias svn grab='svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk '{print $2}' | xargs svn add'

However, there are some single and double quotes in the original command, so the alias fails to be created (ok, it gets created partially, and I can't use it).

How do I escape the single quotes in the command, so the alias will work?

  • Try using a _ in the alias command. Like svn_grab no space in between. What error is it outputting?
    – tron_jones
    Dec 22, 2014 at 13:38
  • With the alias I have tried to set up (see above) I get the following: -bash: alias: svn: not found and -bash: alias: }^[ | xargs svn add: not found. I have changed the name of the alias, so now it only outputs the second error.
    – Rvervuurt
    Dec 22, 2014 at 13:45

1 Answer 1


Double quotes and escaping all " and $ correctly should work:

 alias svngrab="'svn status | grep -v \"^.[ \t]*\..*\" | grep \"^?\" | awk '{print \$2}' | xargs svn add'"

I also would avoid "svn grab" so maybe svngrab or svn_grab instead.

  • I want the alias to be "svn grab", wouldn't it have to be: alias svn grab="'svn status | grep -v \"^.[ \t]*\..*\" | grep \"^?\" | awk '{print \$2}' | xargs svn add'"
    – Rvervuurt
    Dec 22, 2014 at 13:43
  • Yes, I have already changed the alias, because that was also outputting an error.
    – Rvervuurt
    Dec 22, 2014 at 13:50
  • Ok, no more errors, until I started using it just now. It runs the alias until print: and then outputs command not found. The whole line -bash: svn status | grep -v "^.[ \t]*\..*" | grep "^?" | awk {print: command not found. Any idea what's going wrong?
    – Rvervuurt
    Dec 22, 2014 at 15:29
  • @Rvervuurt remove the escape in front of the $
    – klanomath
    Dec 22, 2014 at 15:30
  • @Rvervuurt usually you have to escape $. Maybe it's counterproductive inside the curly brackets {}
    – klanomath
    Dec 22, 2014 at 15:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .