program.c program
#include <stdio.h>
int main() {
int a = 36;
int b = 6;
printf("The answer to life, the universe,\
and everything: %d\n", a+b);
return 0;
}
$ gcc program.c -o program
program.py
a = 36;
b = 6;
print("The answer to life, the universe,\
and everything: {}".format(a+b))
$ python everything.py
The answer to life, the universe, and everything: 42
program.c program
#include <stdio.h>
int main() {
int a = 36;
int b = 6;
printf("The answer to life, the universe,\
and everything: %d\n", a+b);
return 0;
}
$ gcc program.c -o program
$ ./program
We know the answer is 42, but what is the question?
program.py
a = 36;
b = 6;
print("The answer to life, the universe,\
and everything: {}".format(a+b))
$ python everything.py
The answer to life, the universe, and everything: 42
How programs can be called: firefox, steam, discord, grep
cd ls echo/printf
cat, other commands we might use in the scripts
If Statement:
if COMMAND; then
# Insert more commands here
fi
If Statement:
if COMMAND; then
# Insert more commands here
fi
if COMMAND; then
# Insert more commands here
else
# Do otherwise
fi
If Statement:
if COMMAND; then
# Insert more commands here
fi
if COMMAND; then
# Insert more commands here
else
# Do otherwise
fi
if [[ 2 -eq 2 ]]; then
# Insert more commands here
else
# Do otherwise
fi
- Piping - If Statement: - && and || - For loops: - How the scripts actually work - functions, associative arrays, string substition, etc. - Look at a good cheatsheet
#!/usr/bin/env bash
COURSE_ID="123456"
API_TOKEN="12345~..."
mkdir -p files/
FILES=$(
curl
-X GET
-H "Authorization: Bearer $API_TOKEN" \
https://canvas.ucsd.edu/api/v1/courses/$COURSE_ID/files |
jq -r '.[] | "\(.filename),\(.url)"'
)
echo "$FILES" | while IFS= read -r line; do
FILENAME=$(echo $line | awk -F',' '{print $1}')
URL=$(echo $line | awk -F',' '{print $2}')
echo "Downloading $FILENAME..."
curl -s "$URL" -o "$FILENAME"
mv "$FILENAME" "files/$FILENAME"
done
echo "Done! All your files are in the 'files/' directory."
Trying to braek the bounds of the perhaps margin on this thing. They contain the maximum size of content for slides.
#!/bin/bash
# Descr: Bash Script for Bash Workshop
printf "Hi, how are you doing?\n"
firefox
wget -k -m -r https://ieeeucsd.org/
#!/bin/bash
# Descr: Bash Script for Bash Workshop
printf "Hi, how are you doing?\n"
firefox
wget -k -m -r https://ieeeucsd.org/
One
Two
Three
One
Two
Three