View Full Version : [ubuntu] Questions about including a History expand in alias

April 15th, 2011, 01:19 AM
Hey, I try to create an alias that contains a history expand. I have worked on this for hours and I desperately need help. Thanks.

I tried
alias Echo='echo \!*'; which works on the other linux machine.
Also, I tried Echo='echo `history -p`', which works fine. However, when I try to use the same thing for my command, like
alias Bacd='cd Home/Ba `history -p`'.
It is not working.


April 15th, 2011, 01:28 AM
You mean editing bashrc to make an alias to run the history command?

gedit ~/.bashrcAdd an alias at the bottom like

alias hh='history'Then save, close gedit, close your terminals and re-open them

April 15th, 2011, 10:22 PM
Hey, thanks for replying.
My issue is that I want to include a history expand in my alias.
Say I want to copy a file a directory, which is almost the same every time, but the file name would be different.

I want to create an alias like this,

alias Cpfile='cp ~/Work/ \!*'.

\!* is the code I try to use to accomplish that.

When I want to copy things, say macro.i from ~/Work/ directory, I just need to use the command

Cpfile macro.i ~/Newfold

However, this is not working.