Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alias in bash not working [closed]

Tags:

linux

bash

alias bp="cat $@ > [email protected]"

My second idea was:

alias bp="cp $@{,.BACK}"

So i want to have a command to backup a file. It does not raise any error but it simply doesn't work.

like image 566
Art.py Avatar asked Apr 03 '12 17:04

Art.py


1 Answers

Aliases are purely a textual replacement. If you want to use or manipulate the arguments, you need to create a function:

bp () {
  for file; do 
      cp -i "$file" "$file".BACK
  done
} 
like image 130
Kevin Avatar answered Sep 26 '22 03:09

Kevin