In this lab, I ran 3 common terminal commands (cd, ls, and cat) with either no arguments, a path to a directory as an argument, or a path to a file as an argument. I ran these commands in an Edstem workspace where I had cloned the lecture1 repository. These are my observations.
cd /home/lecture1
$ cd
/home. If there are no arguments given, cd simply changes the directory to the home directory.cd simply changes the directory and there was no error./home/lecture1
$ cd messages
/home/lecture1/messages.
This happened because the current working directory (/home/lecture1) was combined with the relative file path (messages) to make the absolute file path of /home/lecture1/messages,
and the current working directory was changed to that.cd simply changes the directory and there was no error./home/lecture1/messages
$ cd en-us.txt
bash: cd: en-us.txt: Not a directory
/home/lecture1/messages/en-us.txt. You can only cd to a directory, not a file.
So, there is an error saying that the file is not a directory.ls /home/lecture1
$ ls
Hello.class Hello.java messages README
/home/lecture1 directory contains 3 files: Hello.class, Hello.java, and README. It also contains 1 directory, nessages. These were all printed out in the output because ls with no arguments lists the names of files and directories in the current working directory./home/lecture1
$ ls messages
en-us.txt es-mx.txt sv.txt zh-cn.txt
ls prints out the names of files and directories in a given directory. Here, the directory was /home/lecture1/messages, which contains 4 files named en-us.txt, es-mx.txt, sv.txt, and zh-cn.txt./home/lecture1
$ ls Hello.java
Hello.java
/home/lecture1/Hello.java is the file itself. Thus, Hello.java is printed.cat /home/lecture1
$ cat
some text
some text
cat simply takes the input and prints it as output./home/lecture1
$ cat messages
cat: messages: Is a directory
messages refers to the directory at /home/lecture1/messages.messages is a directory, there is no text to concatenate./home/lecture1/messages
$ cat en-us.txt
Hello World!
/home/lecture1/messages/en-us.txt was printed. If there were multiple files as arguments, they would be concatenated and printed one after the other. But since there was just one file as an argument, the text in en-us.txt was simply outputted.Here is an example of multiple files being concatenated:
$ cat en-us.txt es-mx.txt
Hello World!
¡Hola Mundo!