Intro to Programming Teaching Assistant --- week1
For context, I was selected for the post of Teaching Assistant for the introductory computer programming course at Bits Pilani.
Even though the course covers the basics of C programming and the Unix command line, I will spend about 15-30 min revising my concepts before each class, which would serve two purposes, the most important one being that I would n’t want the professor who selected me regretting his decision and secondly, so that I can work on some fundamentals which I may not have completely grasped.
The posts will have notes which would help in better understanding the fundamentals of the course.
Agenda
Unix command line basics — cd, cat, wc, ls, pwd, rm, mkdir, touch
Notes
-
Creating empty files
Another way to create empty files (apart from
touch
) is to use output redirection (>)$ > file1.txt
For multiple files,
$ > file1 > file2 > file3
-
significance
Internally, “>” sets stdout to whatever is on the left of the operator. Another other command is evaluated with respect to the above change.
$ > file1.txt pwd
The above example would lead to file1.txt having my current location.
$ cat f1 > f2 > f3
The result of the above example would be that f2 is created empty while f1 is copied into f3. The reason being that the above is evaluated from left to right and
cat
is evaluated at the end. First step is to make f2 the recipient of output which is nothing(since cat is evaluated later). Check this stackoverflow question. -
$ \ $
-
Deleting directories
rmdir
works only for emtpy directories butrm -r
works even for non empty directories. Sometimes,rm -rf
would be required if “force” is required