# Week 4 overview ## Learning objectives: 1. Review: grep, output redirect and appending 1. Creating and editing text files 1. Introduction to shell scripting ## Final project planning: 1. [Choose your case](https://forms.gle/5Gqcownorph3gjzcA) ### Tue. Feb. 11 activities: 1. Go to your atm350 directory and create a new directory named 250211 1. change into the /data1/surface/sao directory 1. list the contents of that directory 1. View the contents of the 25021118_sao.wmo file 1. Search all files in that directory from 250211 that contain the string *TSSN* 1. As above, but redirect the output of the results of that command to a file named `cantore_loves_this.txt` in your /spare11/atm350/\/250211 directory 1. Search all files in the /data1/surface/sao directory from Feb 08 that have that same string 1. As above, but append the output to your `cantore_loves_this.txt` file 1. cd to your 250211 directory 1. Edit `cantore_loves_this.txt` and add a descriptive line to the top of that file 1. Create a text file 1. Add to the file the following lines: ``` #!/bin/sh echo "This is my first bash script" cp /data1/forecasts/250218.disc . # Get number of lines containing the string "snow" grep -c snow 250218.disc # Get number of actual instances of the word "snow" grep -cow snow 250218.disc # Copy some local storm reports cp /spare11/atm350/common/feb11/* . echo "End of script!" exit 0 ``` 13. Save the file as `myscript.sh`. 14. Try to execute the script: type `./myscript.sh` 15. `chmod +x myscript.sh` 16. Try again to execute the script: type `./myscript.sh` ## HW1 [Homework 1](https://docs.google.com/document/d/1_sWaYja7ahNF7KrF7ovIY68z946mc3QxEs60RPGdnI4/edit?usp=sharing): Due Tue, 2/18, 3PM ### Thu. Feb. 13 activities: 1. In your atm350 directory, create a `250213` directory and `cd` into that directory 1. `cp /spare11/atm350/common/feb13/* .` 1. HW 1 comments and questions 1. [IA State Local Storm Report Archive](https://mesonet.agron.iastate.edu/lsr/) 1. Download a geojson file from Jupyterlab 1. Visualize the geojson file on https://geojson.io 1. [Iowa State Mesonet Text Product Archive Documentation](https://mesonet.agron.iastate.edu/cgi-bin/afos/retrieve.py?help) 1. Interactive retrieval of text products ... e.g. `wget "https://mesonet.agron.iastate.edu/cgi-bin/afos/retrieve.py?pil=AFDALY"` 1. Redirect output of wget 1. IA State product retrieval using a shell script 1. Expand utility and flexibility of the data retrieval shell scripts