2

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

1 Answer 1

7

This is a job for a function.

mvdb() {
    mv ~/dbs/aw ~/dbs/aw-"$1"
}
Sign up to request clarification or add additional context in comments.

1 Comment

i added the alias to bash profile with a single line code, alias mvdb='mv ~/dbs/aw ~/dbs/aw-$1' So, Can I write the function that you had mentioned directly in .bash_profile, or do i need to create a new file containing only this function

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.