1

How to make alias that take argument and interpolate it to file extension to create it? I tired this and this doesn't work :

alias create-bash-file=' echo  "#!/bin/bash" > "$1.sh" '

as $1 is first argument and .sh is file extension and I wanted to make an alias that create a bash file included "#!/bin/bash" but the file name I want to take it as an argument so for example and I will write create-bash-file filename this should generate bash file called filename.sh

Cyrus
  • 84,225
  • 14
  • 89
  • 153

1 Answers1

5

Aliases don't take arguments; functions do.

create-bash-file () {
    echo "#!/bin/bash" > "$1.sh"
}
chepner
  • 497,756
  • 71
  • 530
  • 681