You are on page 1of 2

Institute of Computer Technology

B. Tech Computer Science and Engineering

Sub: Basics of Operating System and Shell Scripting


(2CSE204)

Practical 2: Creating, Viewing and Editing Text files

2.1 STDIN, STDOUT, STDERR

<
>
2>

Using Redirection symbols perform the following given tasks:


1. Copy the last 100 lines of /var/log/message to another file.
2. List the home directory’s hidden and regular file names into a file.
3. Store output and error generated for the following given command into a file
find /etc -name passwd
4. Append output and error generated to an existing file.
2.2 CONSTRUCTING PIPELINES AND TEE COMMAND

Using pipe (|) symbol and tee command perform the following given
tasks:
1. Grab the first line, last line or selected lines from a command output.
2. Count the number of files in any directory. (Hint: use wc and ls commands)
3. Count the number of lines of /etc/passwd, append the output in file.txt and
show it on terminal also.

2.3 EDITING TEXT FILES FROM SHELL PROMPT

Using VIM editor perform the following given tasks:


1. Redirect a long listing of all content in student's home directory, including
hidden directories and files, into a file named editing_final_lab.txt.
2. Remove the first three lines, since those lines are not normal file names. Enter
line-based Visual mode with upper case V.
3. Remove the permission columns for group and world on the first line. In this
step, enter visual mode with lower case v, which allows selecting characters on a
single line only.
4. Remove the time column, but leave the month and day on all lines. (Again, use
the block selection visual mode.)
5. Save and exit.
6. Append a dashed line to the file to recognize the beginning of newer content.
(Using echo command.)
7. Append a full process listing, but only for processes owned by the current user
student and running on the currently used terminal. View the process listing and
send the listing to the file with one command line. (Hint: Use ps u command)

You might also like