Give a valid UNIX command line to achieve each of the following tasks:

a) Change to another directory called CS421
`cd CS421`

b) Delete a file called wrongfile
`rm wrongfile`

c) Rename prog7.c to prog8.c
`mv prog7.c prog8.c`

d) List the contents of the current directory including all file details
`ls -l`

e) Print your current working directory
`pwd`

f) Make a new directory called megadir
`mkdir megadir`

g) Display the contents of a file called smallfile
`cat smallfile`

For the editor you chose to use, what command/action do you use to:

h) Add a new line of code
(Varies depending on the editor, e.g., in `vi`, press `i` to enter insert mode.)

i) Search for a string
(Varies depending on the editor, e.g., in `vi`, press `/` followed by the string.)

j) Save the file
(Varies depending on the editor, e.g., in `vi`, press `:w` to save.)

Answer :

Final answer:

UNIX command-line operations for various tasks include 'cd' to change directories, 'rm' to delete files, 'mv' to rename files, 'ls -la' to list file details, 'pwd' to show the current directory, 'mkdir' to create new directories, and 'cat' to display file contents. In text editors, keys such as Ctrl+F and Ctrl+S are typically used to search for strings and save files, respectively.

Explanation:

To achieve the various tasks outlined in your question, you would use the following UNIX command-line operations:

  • Change directory to 'CS421': cd CS421
  • Delete a file called 'wrongful': rm wrong file
  • Rename 'prog7.c' to 'prog8.c': mv prog7.c prog8.c
  • List all file details in the current directory: ls -la
  • Print the current working directory: pwd
  • Create a new directory called 'Agadir': mkdir Agadir
  • Display contents of 'small file': cat small file

Regarding the chosen editor, you can:

  • Add a new line of code by simply navigating to where you want the new line and typing it in.
  • Search for a string by using the 'search' function, oftentimes initiated by keys like Ctrl + F (dependent on the editor).
  • Save the file with a command like Ctrl + S (also dependent on the editor).