Re: alias VS executable
Antoni V. dixit: >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 3. add it to .mkshrc as function using { … ;} I usually prefer the function way, except for really small stuff of stuff that is required to be implemented as alias. Aliases are handled at parse time and influence current shell state, they also don't take parameters, they just type as if you had typed it yourself in that place. That can be useful… alias sfoo='uxterm -class UXTerm -title uxTerm -u8 -geom 90x35+1+10 -e screen -U -R foo & exit' … but usually isn’t: sprunge() { curl -F 'sprunge=<-' http://sprunge.us } # DuckDuckGo search ddg() { local _q _IFS _IFS=$IFS IFS=+ _q="$*" IFS=$_IFS ${BROWSER:-lynx} "https://duckduckgo.com/?kp=-1&kl=wt-wt&kb=t&kh=1&kj=g2&km=l&ka=monospace&ku=1&ko=s&k1=-1&kv=1&t=debian&q=$_q"; } Way #2 (please use /usr/local/bin/ or ~/.etc/bin/ or so) has its uses as well: aliases and functions are not available in Midnight Commander’s shell, or from an editor (think pipe a selection through an external command, ^K/ in jupp). On the other hand, each call then has fork&exec and disc I/O penalty. In the end, they’re all *mostly* equivalent. bye, //mirabilos -- > Hi, does anyone sell openbsd stickers by themselves and not packaged > with other products? No, the only way I've seen them sold is for $40 with a free OpenBSD CD. -- Haroon Khalid and Steve Shockley in gmane.os.openbsd.misc
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.
alias VS executable
Hello. 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? Thanks everyone.