Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Scripting in Bash

ls
demo				test
gh-inclass-sp26-brownsarahm	tiny-book
kwl-sp26-brownsarahm
cd kwl-sp26-brownsarahm/
ls .git
.git/    .github/
ls .git
.git/    .github/
ls .github/
workflows
ls .github/workflows/
experienceinclass.yml	forgottenexperience.yml	label_badges.yml
experiencereport.yml	getassignment.yml	logger.yml
cat .github/workflows/getassignment.yml
name: Create badge issues (Do not run manually)
on:
  workflow_dispatch

# once you edit, change the name

jobs:
  get-assignments:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v6
    
    # Install dependencies
    - name: Set up Python 
      uses: actions/setup-python@v6
      with:
        python-version: 3.12
    
    - name: Install Utils
      run: |
        pip install git+https://github.com/compsys-progtools/courseutils@main
    - name: Get badge requirements
      run: |
        # prepare badge lines
        pretitle="prepare-"$(cspt getbadgedate --prepare)
        cspt getassignment --type prepare | gh issue create --title $pretitle --label prepare --body-file -
        # review badge lines
        rtitle="review-"$(cspt getbadgedate --review)
        cspt getassignment --type review | gh issue create --title $rtitle --label review --body-file -
        # practice badge lines
        pratitle="practice-"$(cspt getbadgedate --practice)
        cspt getassignment --type practice | gh issue create --title $pratitle --label practice --body-file -
      env:
        GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#  edit the run step above for the level(s) you want. 
#  You should keep the prepare, because they are required for experience badges 
#     You may choose to get only the review or only the practice (and change this any time)
MY_VAR='my_val'
MY_VAR=my_val
echo $MY_VAR
my_val
echo MY_VAR
MY_VAR
echo "MY_VAR"
MY_VAR
for NAME in Brandon Curtis George
> do
> echo $NAME
> done
Brandon
Curtis
George
cd ../gh-inclass-sp26-brownsarahm/
ls
about.md		docs			README.md
abstract_base_class.py	example.md		scratch.ipynb
alternative_classes.py	helper_functions.py	setup.py
API.md			important_classes.py	tests
CONTRIBUTING.md		LICENSE.md
for file in $(ls)
> do 
> echo $file
> done
about.md
abstract_base_class.py
alternative_classes.py
API.md
CONTRIBUTING.md
docs
example.md
helper_functions.py
important_classes.py
LICENSE.md
README.md
scratch.ipynb
setup.py
tests
nano check.sh
cat check.sh
for FILE in $(ls)
do
echo $FILE
wc $FILE -l

done
bash check.sh
about.md
       1       2       9 about.md
wc: -l: open: No such file or directory
       1       2       9 total
abstract_base_class.py
       0       7      43 abstract_base_class.py
wc: -l: open: No such file or directory
       0       7      43 total
alternative_classes.py
       0       6      34 alternative_classes.py
wc: -l: open: No such file or directory
       0       6      34 total
API.md
       0       6      47 API.md
wc: -l: open: No such file or directory
       0       6      47 total
check.sh
       6      11      50 check.sh
wc: -l: open: No such file or directory
       6      11      50 total
CONTRIBUTING.md
       0       9      57 CONTRIBUTING.md
wc: -l: open: No such file or directory
       0       9      57 total
docs
wc: docs: read: Is a directory
wc: -l: open: No such file or directory
       0       0       0 total
example.md
       0      10      55 example.md
wc: -l: open: No such file or directory
       0      10      55 total
helper_functions.py
       0       8      49 helper_functions.py
wc: -l: open: No such file or directory
       0       8      49 total
important_classes.py
       0       6      34 important_classes.py
wc: -l: open: No such file or directory
       0       6      34 total
LICENSE.md
       0       9      38 LICENSE.md
wc: -l: open: No such file or directory
       0       9      38 total
README.md
      21     190    1376 README.md
wc: -l: open: No such file or directory
      21     190    1376 total
scratch.ipynb
       0       4      25 scratch.ipynb
wc: -l: open: No such file or directory
       0       4      25 total
setup.py
       0       7      45 setup.py
wc: -l: open: No such file or directory
       0       7      45 total
tests
wc: tests: read: Is a directory
wc: -l: open: No such file or directory
       0       0       0 total
if test -f docs
> then
> echo "file"
> fi
if test -f setup.py; then echo "file"; fi
file
nano check.sh
cat check.sh
for FILE in $(ls)
do
echo $FILE
if test -f $FILE
then
wc -l $FILE
fi
done
bash check.sh
about.md
       1 about.md
abstract_base_class.py
       0 abstract_base_class.py
alternative_classes.py
       0 alternative_classes.py
API.md
       0 API.md
check.sh
       8 check.sh
CONTRIBUTING.md
       0 CONTRIBUTING.md
docs
example.md
       0 example.md
helper_functions.py
       0 helper_functions.py
important_classes.py
       0 important_classes.py
LICENSE.md
       0 LICENSE.md
README.md
      21 README.md
scratch.ipynb
       0 scratch.ipynb
setup.py
       0 setup.py
tests
cat LICENSE.md
the info on how the code can be reused```

+++{"lesson_part": "main"}

```{code-cell} bash
:tags: ["skip-execution"]
cp check.sh fix_lines.sh
nano fix_lines.sh
bash fix_lines.sh
about.md
abstract_base_class.py
alternative_classes.py
API.md
check.sh
CONTRIBUTING.md
docs
example.md
fix_lines.sh
helper_functions.py
important_classes.py
LICENSE.md
README.md
scratch.ipynb
setup.py
tests
bash check.sh
about.md
       2 about.md
abstract_base_class.py
       1 abstract_base_class.py
alternative_classes.py
       1 alternative_classes.py
API.md
       1 API.md
check.sh
       9 check.sh
CONTRIBUTING.md
       1 CONTRIBUTING.md
docs
example.md
       1 example.md
fix_lines.sh
       9 fix_lines.sh
helper_functions.py
       1 helper_functions.py
important_classes.py
       1 important_classes.py
LICENSE.md
       1 LICENSE.md
README.md
      22 README.md
scratch.ipynb
       1 scratch.ipynb
setup.py
       1 setup.py
tests
ssh -l brownsarahm seawulf.uri.edu
brownsarahm@seawulf.uri.edu's password: 
Last login: Thu Apr  2 12:48:25 2026 from 172.20.24.214
[```

+++{"lesson_part": "main"}

```{code-cell} bash
:tags: ["skip-execution"]
logout
Connection to seawulf.uri.edu closed.
ssh-keygen -f ~/seawulf -t rsa -b 1024
Generating public/private rsa key pair.
Enter passphrase for "/Users/brownsarahm/seawulf" (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/brownsarahm/seawulf
Your public key has been saved in /Users/brownsarahm/seawulf.pub
The key fingerprint is:
SHA256:TXPjoIqwdEQlUZO8mwjgk8Gp37DIgNNg05ltth6BbgM brownsarahm@214.24.20.172.s.wireless.uri.edu
The key's randomart image is:
+---[RSA 1024]----+
|. o O=+.         |
|oE * *o.         |
|=+* + o.  + o    |
|=++= o.  + = .   |
|o+==+..oS . .    |
|.oo+ooo.         |
|  . . .          |
|                 |
|                 |
+----[SHA256]-----+
cd
ls -a
.			.local			Desktop
..			.matplotlib		Documents
.bash_history		.npm			Downloads
.bash_profile		.ollama			Dropbox
.bash_sessions		.python_history		final-grade.md
.bashrc			.Rhistory		final-posted.md
.cache			.ssh			Library
.CFUserTextEncoding	.Trash			miniforge3
.conda			.viminfo		Movies
.config			.vscode			Music
.dropbox		.zprofile		Pictures
.DS_Store		.zprofile.pysave	Public
.gitconfig		.zsh_history		scikit_learn_data
.ipython		.zsh_sessions		seawulf
.jupyter		Applications		seawulf.pub
.lesshst		badges.yml		Zotero
ssh-copy-id -i ~/seawulf brownsarahm@seawulf.uri.edu
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/Users/brownsarahm/seawulf.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
brownsarahm@seawulf.uri.edu's password: 

Number of key(s) added:        1

Now try logging into the machine, with: "ssh -i /Users/brownsarahm/seawulf 'brownsarahm@seawulf.uri.edu'"
and check to make sure that only the key(s) you wanted were added.
ssh -i ~/seawulf brownsarahm@seawulf.uri.edu
Last failed login: Tue Apr  7 13:31:27 EDT 2026 from 172.20.24.114 on ssh:notty
There were 3 failed login attempts since the last successful login.
Last login: Tue Apr  7 13:23:24 2026 from 172.20.24.214
[```

+++{"lesson_part": "main"}

```{code-cell} bash
:tags: ["skip-execution"]
logout
Connection to seawulf.uri.edu closed.
ls -a
.			.local			Desktop
..			.matplotlib		Documents
.bash_history		.npm			Downloads
.bash_profile		.ollama			Dropbox
.bash_sessions		.python_history		final-grade.md
.bashrc			.Rhistory		final-posted.md
.cache			.ssh			Library
.CFUserTextEncoding	.Trash			miniforge3
.conda			.viminfo		Movies
.config			.vscode			Music
.dropbox		.zprofile		Pictures
.DS_Store		.zprofile.pysave	Public
.gitconfig		.zsh_history		scikit_learn_data
.ipython		.zsh_sessions		seawulf
.jupyter		Applications		seawulf.pub
.lesshst		badges.yml		Zotero
ls .ssh/
config		known_hosts	known_hosts.old	seawulf		seawulf.pub
cat .ssh/config
Host seawulf
Hostname seawulf.uri.edu
user brownsarahm
IdentityFile ~/.ssh/seawulf
mv seawulf* .ssh/
ssh seawulf
Last failed login: Tue Apr  7 13:37:46 EDT 2026 from 172.20.67.20 on ssh:notty
There were 8 failed login attempts since the last successful login.
Last login: Tue Apr  7 13:31:48 2026 from 172.20.24.214
[```

+++{"lesson_part": "main"}

```{code-cell} bash
:tags: ["skip-execution"]
logout
Connection to seawulf.uri.edu closed.
## Prepare for Next Class 

```{include} ../_prepare/2026-04-09.md

Badges

Review
Practice
  1. Review the notes from today

  2. Update your KWL Chart learned column with what you’ve learned

  3. write a bash script to make it so that cating the the files in your gh_inclass repo does not make the prompt move

Experience Report Evidence

Questions After Today’s Class