0% found this document useful (0 votes)
1K views6 pages

Unix 1

The document contains instructions for a UNIX assignment involving directory structures, file operations, and commands. It asks the student to: 1) Create a nested directory structure called 'training' with subdirectories. 2) Copy a directory structure from dir1 to dir2 including all subdirectories. 3) Use commands like grep, sed, sleep and jobs to manage files, run background processes, and check process status.

Uploaded by

Ravi Shankar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views6 pages

Unix 1

The document contains instructions for a UNIX assignment involving directory structures, file operations, and commands. It asks the student to: 1) Create a nested directory structure called 'training' with subdirectories. 2) Copy a directory structure from dir1 to dir2 including all subdirectories. 3) Use commands like grep, sed, sleep and jobs to manage files, run background processes, and check process status.

Uploaded by

Ravi Shankar
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

UNIX – Assignment 1

1. Create a tree structure named ‘training’ in which there are 3 subdirectories –


‘level 1’,’ level2’ and ‘cep’. Each one is again further divided into 3. The ‘level 1’ is
divided into ‘sdp’, ‘re’ and ‘se’. From the subdirectory ‘se’ how can one reach the
home directory in one step and also how to navigate to the subdirectory ‘sdp’ in
one step? Give the commands, which do the above actions?

2. How will you copy a directory structure dir1 to dir2 ? (with all the subdirectories)

3. How can you find out if you have the permission to send a message?

4. Find the space occupied ( in Bytes) by the /home directory including all its
subdirectories.

5. What is the command for printing the current time in 24-hour format?

6. What is the command for printing the year, month, and date with a horizontal tab
between the fields?

7. Create the following files: chapa, chapb, chapc, chapd, chape, chapA, chapB, chapC,
chapD, chapE, chap01, chap02, chap03, chap04, chap05, chap11, chap12, chap13,
chap14, and chap15.

8. With reference to question 7, What is the command for listing all files ending in small
letters?

9. With reference to question 7, What is the command for listing all files ending in
capitals?

10. With reference to question 7, What is the command for listing all files whose last but
one character is 0?

11. With reference to question 7, What is the command for listing all files which end in
small letters but not ‘a’ and ‘c’?

12. In an organisation one wants to know how many programmers are there. The
employee data is stored in a file called ‘personnel’ with one record per employee. Every
record has field for designation. How can grep be used for this purpose?

13. In the organisation mentioned in question 12 how can sed be used to print only the
records of all employees who are programmers.
14. In the organisation mentioned in question 12 how can sed be used to change the
designation ‘programmer’ to ‘software professional’ every where in the ‘personnel’ file

15. Find out about the sleep command and start five jobs in the background, each one
sleeping for 10 minutes.

16. How do you get the status of all the processes running on the system? i.e. using
what option?

Available from: Thursday, 25 November 2010, 10:00 AM


Due date: Friday, 3 December 2010, 10:00 AM

Answer-1

Mkdir training training/level1 training/level2 training/cep level1/sdp level1/re level1/se


level2/sdp level2/re level2/se cep/sdp cep/re cep/se

Answer-2

Cp –r dir1 dir2 command will copy a directory structure dir1 to dir2.

Answer-3

Ls lg command is used to find out if you have the permission to send a message.

Answer-4

Ls –l command is used to display all the content of directory along with size in bytes.

Answer-5

Date +%T command is used to display date and time in 24-hour format.

Answer-6

Date +%t command is for printing the year, month, and date with a horizontal tab
between the fields.

Answer-7

Cat > chapa

Contents of file

Ctrl+D

Cat > chapb


Contents of file

Ctrl+D

Cat > chapc

Contents of file

Ctrl+D

Cat > chapd

Contents of file

Ctrl+D

Cat > chape

Contents of file

Ctrl+D

Cat > chapA

Contents of file

Ctrl+D

Cat > chapB

Contents of file

Ctrl+D

Cat > chapC

Contents of file

Ctrl+D

Cat > chapD

Contents of file

Ctrl+D

Cat > chapE

Contents of file
Ctrl+D

Cat > chap01

Contents of file

Ctrl+D

Cat > chap02

Contents of file

Ctrl+D

Cat > chap03

Contents of file

Ctrl+D

Cat > chap04

Contents of file

Ctrl+D

Cat > chap05

Contents of file

Ctrl+D

Cat > chap11

Contents of file

Ctrl+D

Cat > chap12

Contents of file

Ctrl+D

Cat > chap13

Contents of file

Ctrl+D
Cat > chap14

Contents of file

Ctrl+D

Cat > chap15

Contents of file

Ctrl+D

Answer-8

Ls *[abcde] or

Ls *[a-z]

Answer-9

Ls *[A-Z]

Answer-10

Ls *0?

Answer-11

Ls *[bde]

Answer-12

Grep –c programmer personnel

Answer-13

Sed –n ‘/programmer/p’ personnel

Answer-14

Sed ‘s/programmer/software professional/g’ personnel

Answer-15

The command sleep waits a given number of seconds before continuing. Type
% sleep 10
This will wait 10 seconds before returning the command prompt %. Until the command
prompt is returned, you can do nothing except wait.
To run sleep in the background, type

% sleep 10 &

Sleep 600 &

Sleep 600 &

Sleep 600 &

Sleep 600 &

Sleep 600 &

Answer-16

Jobs command is get the status of all the processes running on the system.

You might also like