Artificial intelligent assistant

Alias grep "$1" filename doesn't work, somehow "$1" went missing Normal `grep` wolf@linux:~$ egrep 4.4.4.4 data.csv A,4.4.4.4,4.4.4.5,4.4.4.6,3.3.3.3,3.3.3.4 wolf@linux:~$ Since I've a lot of data to grep, I've put it on alias. wolf@linux:~$ alias z="egrep $1 data.csv" wolf@linux:~$ But it doesn't work wolf@linux:~$ z 4.4.4.4 grep: 4.4.4.4: No such file or directory wolf@linux:~$ It turns out that `$1` was missing from the alias. wolf@linux:~$ alias z alias z='egrep data.csv' wolf@linux:~$ What was the reason behind this?

Try a function instead of alias


z() { egrep -- "$1" data.csv; }


Output


$ z() { egrep -- "$1" data.csv; }
$ z 3.3.3.3
A,4.4.4.4,4.4.4.5,4.4.4.6,3.3.3.3,3.3.3.4
B,1.1.1.1,1.1.1.1,1.1.1.2,1.1.1.3,3.3.3.3
$

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy 9c5762232aefb6d3afbdb956cfc922e6