2

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?

2 Answers 2

2

Using 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 the 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.

1
  • Thanks! The second solution worked after I removed the escape character in front of the !.
    – JJRhythm
    Jul 5, 2012 at 18:56
2

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.

2
  • I tried this and received the same error.
    – JJRhythm
    Jul 5, 2012 at 18:54
  • Sorry, but it works for me.
    – Fran
    Jul 6, 2012 at 17:21

You must log in to answer this question.

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