Article 4Y6C0 How can I use a parameter with an alias?

How can I use a parameter with an alias?

by
dave555
from LinuxQuestions.org on (#4Y6C0)
Hello

I need a little help with this. I am making an alias to create a password quickly.

This works:

Code:alias makepw="cat /dev/urandom | tr -cd '[:alnum:]%$#-' | head -c 15 ; echo"
~ % makepw
9oFpSu4N%5VDIYFHowever, when I change to head -c $1, I get this error
Code:alias makepw="cat /dev/urandom | tr -cd '[:alnum:]%$#-' | head -c $1 ; echo"
~ % makepw 19
head: option requires an argument -- 'c'
Try 'head --help' for more information.
19I'm trying to use $1 as an argument to pass different lengths for a password.

PS: The command without the alias part works fine if used in it's own shell script file, BUT I want to use it as an alias in my .bashrc file.

Any ideas what I am doing wrong? Thanks in advancelatest?d=yIl2AUoC8zA latest?i=LLhGNvgZZm8:hhS2Em2qjb0:F7zBnMy latest?i=LLhGNvgZZm8:hhS2Em2qjb0:V_sGLiP latest?d=qj6IDK7rITs latest?i=LLhGNvgZZm8:hhS2Em2qjb0:gIN9vFwLLhGNvgZZm8
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments