[TriLUG] Single line scripts

Aaron Morrison via TriLUG trilug at trilug.org
Mon Sep 5 20:50:36 EDT 2016


Don't forget shell aliases (and in some cases functions)

I have some dozen or so aliases to do some menial jobs that are not complicated enough for a script but very tedious to type every time. I keep them in my .bashrc file that I have in source control and push to every server I have an account for. I also make use of environment variables for some of them to be more generic and flexible.  It's simple and I only have to maintain one file. 

For a similar example, I have an alias named "rdp" that calls xfreerdp/rdesktop with all of the needed parameters and pass any arguments to the aliased command (such as a hostname)

--am


> On Sep 5, 2016, at 20:32, Ken MacKenzie via TriLUG <trilug at trilug.org> wrote:
> 
> Single line scripts.  I will say a script that is effectively used to call
> a long single command line, yeah plenty of times.  I am lazy and
> forgetful.  The last thing I want to do is type the same thing twice, even
> worse is type it then have to remember later how it is laid out and it is
> too long ago to up arrow my way to it.  So yeah I make plenty of quick
> helpers, say to connect to a device for a vnc over ssh tunnel or what not
> sort packages by install size, you name it.
> 
> My work's RDP setup uses ts gateway and xfreerdp command line is the only
> way though it so that is one I used a lot.  It was a single line till I
> turned it into a quick python program in stead but the point remains.
> 
> In the end though they are never single line because at the minimum they
> contain:
> 
> #!/bin/bash (or /bin/python or /bin/perl or bin/whatever)
> 
> # why my dumb butt needed to make this
> 
> cmd....
> 
> Oh I tend to keep them in under my home, not in a place in the path, and I
> have stopped using extensions (like .sh or ,py) once in a "production"
> usage.  I just get in the habit of ./something or ~/scripts/something when
> I need to call them.
> 
> Ken
> -- 
> This message was sent to: Aaron Morrison <ae4ko1 at gmail.com>
> To unsubscribe, send a blank message to trilug-leave at trilug.org from that address.
> TriLUG mailing list : http://www.trilug.org/mailman/listinfo/trilug
> Unsubscribe or edit options on the web    : http://www.trilug.org/mailman/options/trilug/ae4ko1%40gmail.com
> Welcome to TriLUG: http://trilug.org/welcome


More information about the TriLUG mailing list