Les Partages de Memiks
Tag cloud
Picture wall
Daily
RSS Feed
  • RSS Feed
  • Daily Feed
  • Weekly Feed
  • Monthly Feed
Filters

Links per page

  • 20 links
  • 50 links
  • 100 links

Filters

Untagged links
1 result tagged parameter  ✕
Make a Bash alias that takes a parameter? - Stack Overflow https://stackoverflow.com/questions/7131670/make-a-bash-alias-that-takes-a-parameter
Thu Dec 14 14:31:34 2017 archive.org
QRCode
thumbnail

Bash alias does not directly accept parameters. You will have to create a function and alias that.

alias does not accept parameters but a function can be called just like an alias.

For example:

myfunction() {
#do things with parameters like $1 such as
mv "$1" "$1.bak"
cp "$2" "$1"
}

myFunction xyz #calls myfunction

By the way, Bash functions defined in your .bashrc and other files are available as commands within your shell. So for instance you can call the earlier function like this

$ myfunction original.conf my.conf

bash alias parameter
4756 links, including 1670 private
Shaarli - The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community - Theme by kalvn