I know I can do tail -f filename | grep string
tail -f filename | grep string
to grep just the string I want from a log file. I am trying to create an alias on .bashrc to do this. I tried alias log='tail -f $1 | grep $2'
alias log='tail -f $1 | grep $2'
but it's not working. Can any one please point out the correct way of doing this.
You can't use parameter with an alias. To do it, put a function like this in ~/.bashrc :
tailgrep(){ tail -f "$1" | grep "$2"; }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.