O'Reilly logo

Expert Shell Scripting by Ron Peters

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required