If your program is fred which accepts input from standard input then just type fred (return) followed by typing in your input. In UNIX end with a control-D character. In windows end with a control-Z character.
Standard output is the character output to the terminal window you are using.
fredit waits for you to type.
Redirection If you put a < then it redirects input from a file. To input from file "dogs" into command fred then type:
fred < dogs
If you put a > then it redirects standard output to a file. If fred outputs to standard output then
fred > catswill write the output of fred to the file cats
To create a tar file you use the unix tar command. To put the files cats and dogs into tar file animals.tar do:
tar cvf animals.tar cats dogsWARNING: don't forget to put the name of the tar file (animals.tar) in or you could OVERWRITE your files!
To unpack a tar file
tar xvf animals.tarTo list the table of contents of a tar file animals.tar
tar tvf animals.tar
A correctly configured UNIX system (OS X included) has manual pages that can be accessed by invoking the man command. Suppose you want to know more about the sort command. Type this
man sortto get the manual page or "man page".
make is a dependency driven build tool. It allows you to rebuild only the parts of your project that have changed. I provide a make primer to show you on the general features of make. However, for a single flex file (see flex primer) you only need to put this into a file called makefile in the same directory as your code.
BIN = tree CC = g++ CFLAGS = -g -DCPLUSPLUSSRCS = $(BIN).l OBJS = lex.yy.o LIBS = -lfl
$(BIN): $(OBJS) $(CC) $(CCFLAGS) $(OBJS) $(LIBS) -o $(BIN)
lex.yy.c: $(BIN).l flex $(BIN).l
NOTE: the lines that begin with whitespace begin with exactly one tab (I am not kidding).
If you execute the program make it will look in the directory in which it was executed for a file named makefile and use that to direct a build in that directory. For example, suppose you had a file tree.l (the only file that you need to build) you wanted to turn in for an assignment you could:
sdiff stands for "side by side difference". It is a UNIX command used to compare the output of your program to the expected output. Here is how to read the output of sdiff. Assume you have two files bigthings is a list of big things and mammals is a list of mammals. The files are alphabetized and tend to have some overlap. Here is bigthings:
cows horses houses planets trucks zebraHere is mammals:
cowz elephants horses zebraexecuting the command:
sdiff bigthings mammalswould give you this output:
cows | cowz
> elephants
horses horses
houses <
planets <
trucks <
zebra zebra
The two files are presented side by side with a central column with one of
4 characters: |, <, >, space. These mean:
Note: sdiff tries to get the lines to "line up" in sequence. A random reordering of one file tends to make all the lines not match.
In the above example 3 things are in bigthings that are not in mammals, 1 thing is in mammals that is not in bigthings, and 1 thing is a line that is has been substituted for another.
Check the man page for sdiff for the options, in particular the -w option.