# Shell Scripts

* Shell scripts are sequential collection of commands that generally represent a workflow.
* Shell scripts can use other commands as building blocks.

### **Example**

Suppose that occasionally you want the system to tell you some simple information, like your user id, the current directory and its content, and display the current date. To avoid typing this sequence of commands every time you want to know this information, you can compose a short script that execute the commands in a specific order.

* Open a text editor (e.g. nano).
* Type the sequence of commands to execute in the specific order they should be executed.

```
clear
echo Today date is:
date
echo
echo Your current directory is:
pwd
echo
echo The files in your current directory are:
ls -lt
echo
echo Have a nice day!
```

<figure><img src="/files/JPrfDiacvBWgOE7sveGI" alt=""><figcaption></figcaption></figure>

* Save the file by giving to the script a meaningful name, for example info.sh.

<figure><img src="/files/smh5czL4Fkk61hLtNSkb" alt=""><figcaption></figcaption></figure>

* Execute the command by invoking your shell (e.g. bash) followed by the script name. If you don't know what shell you are running, type "echo $SHELL" at the prompt.

```
bash info.sh
```

<figure><img src="/files/3boffHjcqUZrKRX0LYoa" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://igb.mit.edu/mini-courses/introduction-to-unix-and-ki-computational-resources/basic-unix/shell-scripts.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
