Week 4 overview#
Learning objectives:#
Review: grep, output redirect and appending
Creating and editing text files
Introduction to shell scripting
Final project planning:#
Tue. Feb. 11 activities:#
Go to your atm350 directory and create a new directory named 250211
change into the /data1/surface/sao directory
list the contents of that directory
View the contents of the 25021118_sao.wmo file
Search all files in that directory from 250211 that contain the string TSSN
As above, but redirect the output of the results of that command to a file named
cantore_loves_this.txt
in your /spare11/atm350/<netid>/250211 directorySearch all files in the /data1/surface/sao directory from Feb 08 that have that same string
As above, but append the output to your
cantore_loves_this.txt
filecd to your 250211 directory
Edit
cantore_loves_this.txt
and add a descriptive line to the top of that fileCreate a text file
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
Save the file as
myscript.sh
.Try to execute the script: type
./myscript.sh
chmod +x myscript.sh
Try again to execute the script: type
./myscript.sh
HW1#
Homework 1: Due Tue, 2/18, 3PM
Thu. Feb. 13 activities:#
In your atm350 directory, create a
250213
directory andcd
into that directorycp /spare11/atm350/common/feb13/* .
HW 1 comments and questions
Download a geojson file from Jupyterlab
Visualize the geojson file on https://geojson.io
Interactive retrieval of text products … e.g.
wget "https://mesonet.agron.iastate.edu/cgi-bin/afos/retrieve.py?pil=AFDALY"
Redirect output of wget
IA State product retrieval using a shell script
Expand utility and flexibility of the data retrieval shell scripts