#!/bin/bash
# COMP 198  Spring 2026
# bash2.sh
# More on evaluation and input

name="Joe Schmoe"	
echo "Hello," $name     # displays: Hello, Joe Schmoe
echo "Hello, $name"     # displays: Hello, Joe Schmoe - SAME!
								# this is "shell substitution"
echo 'Hello, $name'     # displays: Hello, $name - $ loses special meaning in ''
dir_count=`ls | wc -l`	# BACK quotes - for use in evaluating Linux commands
echo $dir_count         # displays the number of items in directory

echo "Reading stuff..."
read var1               # will read all of one line (input "this is input")
echo "var1:" $var1      # output: "var1: this is input"
read var1 var2          # will read ONE item into var1, rest in var2
echo "var1:" $var1 "var2:" $var2	# output: "var1: this var2: is input"

echo "Can read/write stuff with files"
read var1 var2 < myinput   # myinput contains: "1 2 3"
echo $var1 > myoutput      # prints output to the file "myoutput"
echo $var2 >> myoutput     # APPENDS var2 to file "myoutput"; file contains 1//2 3

