Masade
Masade

Reputation: 716

How to add arguments in custom bash commands?

I am trying to add custom variable in a bash script alias command and not able to do it

I added the following in .bash_profile file

alias mvdb='mv ~/dbs/aw ~/dbs/aw-$1'

In the command line I am trying to run a script

mvdb "2017OCT20"

I want the folder named aw to be renamed as aw-2017OCT20 when I run command

Upvotes: 2

Views: 2050

Answers (1)

John Kugelman
John Kugelman

Reputation: 361595

This is a job for a function.

mvdb() {
    mv ~/dbs/aw ~/dbs/aw-"$1"
}

Upvotes: 7

Related Questions