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.

I can run,

 svn status |grep -v .jasper$ |cut -d ' ' -f8 |sed '/.*\..*/!d' |xargs ls -altr --color=auto

just fine. But when I go to add this as an alias (alias svtr="...") I get an error saying...

-bash: !d': event not found

Any ideas?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

use backslash \ to escape your ! should work.

alias svtr="svn status |grep -v .jasper$ |cut -d ' ' -f8 |sed '/.*\..*/\!d' |xargs ls -altr --color=auto"
alias svtr
alias svtr='svn status |grep -v .jasper$ |cut -d '\'' '\'' -f8 |sed '\''/.*\..*/\!d'\'' |xargs ls -altr --color=auto'

actually, that just eliminates thhe error, because inside "" the shell tries to interpret !.

you may want to revert quotes (i.e., use singlequote to define alias, and use doublequote inside the aliased command, and escape singlequotes where necessary.

share|improve this answer
    
Thanks! The second solution worked after I removed the escape character in front of the !. –  JJRhythm Jul 5 '12 at 18:56
add comment

The !d in your sed command is causing this, because ! is the Bash history expansion character. Temporarily turn off history expansion, like this:

set -H
alias svtr="..."
set +H

That should do it.

share|improve this answer
    
I tried this and received the same error. –  JJRhythm Jul 5 '12 at 18:54
    
Sorry, but it works for me. –  Fran Jul 6 '12 at 17:21
add comment

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.