Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How to make this an alias in zsh?

svn status | grep "^?" | awk -F "      " '{print $2}' | tr "\n" "\0" | xargs -0 svn add

I know it should be something along the lines:

alias sall = "the command"

But as the line mixes " with ' I don't know how to handle that.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

You can use " for your awk command.

alias sall='svn status | grep "^?" | awk -F " " "{print $2}" | tr "\n" "\0" | xargs -0 svn add'

should work.

share|improve this answer
    
The escaped characters version gives an error about a ' not being matched. But the first version works, if you make it alias sall='svn st...' (no whitespace) –  Nerian Feb 17 '11 at 17:54
    
@Nerian: If you use double quotes around the awk command, you'll need to escape the dollar sign: awk -F " " "{print \$2}" –  Dennis Williamson Feb 17 '11 at 17:55
2  
Sorry, Bash needs it. Apparently zsh doesn't. After trying both, I see the difference. –  Dennis Williamson Feb 17 '11 at 17:57

Use a function.

sall() {
    svn status | sed -rn 's/^\? {7}//p' | xargs -d '\n' svn add
}

(Since svn uses newline as output separator, it makes no sense to convert it to null and back.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.