How can I save commands to re-run later?
You have been using the shell interactively so far.
But since the commands you type in are just text,
you can store them in files for the shell to run over and over again.
To start exploring this powerful capability,
put the following command in a file called headers.sh
:
head -n 1 seasonal/*.csv
This command selects the first row from each of the CSV files in the seasonal
directory.
Once you have created this file,
you can run it by typing:
bash headers.sh
This tells the shell (which is just a program called bash
)
to run the commands contained in the file headers.sh
,
which produces the same output as running the commands directly.
This exercise is part of the course
Introduction to Shell
Hands-on interactive exercise
Turn theory into action with one of our interactive exercises
