Create alias with paramater in the middle [duplicate]
Aliases do not support positional parameters so you need to create a function (which you can put in ~/.bashrc
). If you really want and alias, you could alias that function.
function grepMe(){
grep "$1" ~/myfile
}
Then, if for some reason you want there to be an alias, you can make one for the function:
alias grepAlias="grepMe"
Alias don't supports parameter but you can write a small script and name it i.e. "filegrep"
#!/bin/bash
grep "$1" /home/youruser/myfile
Copy the script to /usr/bin
and you can run it with filegrep argX
in the console.