#!/bin/csh -f
#
# Remember, every shell script must have permissions set to execute. Remember to "chmod +x foo.csh" where
# foo.csh is the file containing your shell script.
#
# Each command below comes with its own man page. Eg, "man awk"
#
#

# print something
echo "hello mom."

# what time is it?
date

# count the number of lines in this shell script
echo "line count for sample-shell-script.csh"
wc -l sample-shell-script.csh

# make a file with 5 numbers in it.
cat > datafile <<EOF
23 abc
43 def
1 abc
5 lmn
2 opq
EOF

# sort the file lexically
echo "Lexical sort"
sort < datafile


# sort the file numerically and put the results in a new file
echo "Numeric sort"
sort -n < datafile > datafile.sorted

# extract the second field of the sorted data file
echo "Second field"
awk '{print $2}' < datafile.sorted

# filter the file for "abc"
echo "filtering for abc"
grep "abc" datafile.sorted

# filter the file for NOT abc and count the number of occurrences
echo "counting lines NOT abc"
grep -v "abc" datafile.sorted | wc -l

# compare the sorted and unsorted files.
echo comparing files
diff datafile datafile.sorted

# put the first and 7th fields (tab separated) from the first 
# top ten lines of the tcpdump trace file in text format and precede each with a line number
echo extracting fields. See results in 10lines.txt
tcpdump -ttt -r bigtrace.raw | head -10 | awk '{printf("%s\t%s\n",$1,$7)}' | cat -n > 10lines.txt







