[sf-lug] dumb little command-line trick

jim jim at well.com
Sun Aug 7 22:15:08 PDT 2016


(optional reading)
     (I used to teach intro programming classes
and miss it.) This is for people getting
started using the command-line.
------------------------------------------------
     Some command-line users I admire issue
a command, watch its output, and then hit
the  Enter  key a few times to create some
blank lines that make some space between
the output of the command and the command
that they next invoke:

$ doit
this and that and more
$
$
$
$ icommandyou be good
gurgle burble

     I invoke the  doit  command, which prints
its output (this and that and more) then I hit
the  Enter  key three times and then invoke
the  icommandyou be good  command, which
prints its output (gurgle burble). I review
what I've done and have convenient blank lines
separating the two different commands and their
outputs.


     My dumb little trick is similar, but I use
the  echo  command and the  ;  (semi-colon)
command-separation character and then the command
I want to run.

$ echo "


" ; doit



this and that and more
$

     For those interested, my trick has three parts,

echo "


"
## what this does it to print three blank lines
to the display.

as well as

;
## what this does is to tell the shell that
everything to the left is a command and
everything to the right is a completely
different command. (The shell has other
command-line termination characters, such
as > and >> and < and << and | and more.)

doit
## this is the command I want to run.

     My dumb little command-line trick lets me
run a command but issue a few blank lines
before the command runs, so I get a little
blank space above the output of the command.

     I can make a shell script that saves a
little time and possible typing errors.

$ pwd
/home/jim/bin  ## here's my current directory
$ echo $PATH
/home/jim/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
## I set my PATH environment variable to include my
own  bin  directory, /home/jim/bin

$ vi blns
echo "


"
$ chmod 755 blns

     Now I can use my dumb little trick like this

$ blns ; doit

## I suppose I could have put the  ;  command
## separation character in the shell script,
## but for some reason I feel better making
## myself type that character

## I made up the name  blns  to suggest "blank lines".






More information about the sf-lug mailing list