CHAPTER 16Scripting from the CommandLine

One of the advantages of working at the shell command line is that you're working in a shell. That sounds sort of obvious and dumb, but please bear with me; pretty much anything you can do in a shell script, you can also do from the command line. I've coded many ad hoc scripts right at the command line. I wouldn't recommend writing anything significant that way, but for quickies it's just the ticket.

If you start a loop or conditional, such as a while, for, or if/then statement, while working at the shell prompt, the command line is extended until you have finished the steps in the code block. In a traditional script, such code would customarily span several lines in a file. Here is a typical interaction ...

Get Expert Shell Scripting now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.