Re: alias VS executable
Op 01-10-16 om 20:03 schreef Antoni V.: > I use a command many times on a day to check what programs are using internet. > netstat -lantp | grep -i stab | awk -F/ '{print $2 $3}' | sort | uniq > Then I thought of making a shortcut for it called 'using'. > I can think of 2 ways. > > 1- add it to .mkshrc as \alias using= > 2- create /usr/bin/using (chmod +x) and add the one liner to it > > Both will work the exact same way. > So I think, which one is better? Faster? Making it an external command is fine; the speed difference is going to be negligible in comparison to the pipeline of external commands you're launching. If you want to use .mkshrc, best use a shell function instead of an alias. It avoids the shell-grammatical snags you get when you create an alias out of a compound command. So add this to .mkshrc: function using { netstat -lantp | grep -i stab | awk -F/ '{print $2 $3}' | sort | uniq } HTH, - M.
Re: alias VS executable
On Sat, Oct 01, 2016 at 09:03:15PM +0200, Antoni V. wrote: Hi, > netstat -lantp | grep -i stab | awk -F/ '{print $2 $3}' | sort | uniq > >[…] > > 1- add it to .mkshrc as \alias using= > 2- create /usr/bin/using (chmod +x) and add the one liner to it > > Both will work the exact same way. > So I think, which one is better? Faster? Better: it depends from where you call it. When it's exclusively interactively from a terminal, I personaly make an alias to not encumber my PATH (more). Faster: don't bother, you can't however humanly notice it. (BTW, I think you might shrink it a bit: netstat -lantp | grep -i stab | awk -F/ '{print $2 $3}' | sort -u or, if you want to save the grep process: netstat -lantp | awk -F/ '/[sS][tT][aA][bB]/{print $2 $3}' | sort -u ) My 2 cents. ++ Seb.