How to make an alias from a statement with many : " and many : '

2

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.

Nerian

Posted 2011-02-17T17:29:45.483

Reputation: 1 237

Answers

5

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.

Olli

Posted 2011-02-17T17:29:45.483

Reputation: 6 704

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 – 2011-02-17T17:54:57.100

@Nerian: If you use double quotes around the awk command, you'll need to escape the dollar sign: awk -F " " "{print \$2}" – Paused until further notice. – 2011-02-17T17:55:15.977

2Sorry, Bash needs it. Apparently zsh doesn't. After trying both, I see the difference. – Paused until further notice. – 2011-02-17T17:57:25.520

1

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.)

user1686

Posted 2011-02-17T17:29:45.483

Reputation: 283 655