0% found this document useful (0 votes)
53 views

UNIX Assignment 2

The document provides instructions for completing an assignment on working with files and directories in Unix shell scripting. It includes 9 tasks: 1) Create directories, 2) Move between directories and list processes, 3) Find the current working directory, 4) Display files with a certain extension or starting with a letter, 5) List files matching a naming pattern, 6) List files without numbers in their names, 7) Display a file's contents, 8) Create and copy files, and 9) Move a file's contents to another file. For each task, it provides the commands to use to complete the task, such as mkdir, pwd, find, ls, cp, and mv.

Uploaded by

bharatshrawagi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views

UNIX Assignment 2

The document provides instructions for completing an assignment on working with files and directories in Unix shell scripting. It includes 9 tasks: 1) Create directories, 2) Move between directories and list processes, 3) Find the current working directory, 4) Display files with a certain extension or starting with a letter, 5) List files matching a naming pattern, 6) List files without numbers in their names, 7) Display a file's contents, 8) Create and copy files, and 9) Move a file's contents to another file. For each task, it provides the commands to use to complete the task, such as mkdir, pwd, find, ls, cp, and mv.

Uploaded by

bharatshrawagi
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Course: Unix Shell Scripting for Beginners

User Assignment 2 - Working with Files and Directories

1. Create a directory called iiht and inside it creates three sub directories namely, trainers,
trainees and employees.
Ans : Use commands as follows,
mkdir iiht
cd iiht
pwd
mkdir namely
mkdir employers
mkdir trainees and employees
2. Move to employee’s directory and list all the process, then get back to the home directory.

Ans : Use following commands,


cd iiht - To move to iiht directory
cd employees - To move to employee’s directory
ps - To list all processes
cd - To get back to home directory
3. Find the current working directory.

And : Use ‘pwd’ command to find current working directory.


4. Display all files which has .txt extension and display all the files whose name starts with ‘n’

Ans : Use ‘find -name “.txt” -print’ command to display .txt file and
Use ‘ls -d /etc/ [n]* command to files whose name start with ‘n’
5. List all files which are having first letter as A and last character as a in between any 4
characters.

Ans : Use ‘find -name “*[A!!!!a]” -print’ command to display all files which are having
first letter as A and last character as a in between any 4 characters.
6. List all files which does not have any numeric values in their file names.

Ans : Use ‘find -name “*[!(0-9)]” -print’ command to list all files which does not have
any numeric values in their file names.
7. Display the contents of a specified file in the directory.

Ans : Use ‘ ls / iiht’ command to display the contents of a specified file in the directory.
8. Create a file called first.txt and insert some content into and copy the contents to second.txt
file.

Ans : Use ‘cat > first.txt’ command to create a new file.


Use ‘cp first.txt second.txt’ command to copy contents to second .txt.
9. Move the contents from second.txt to final.txt

Ans : Use ‘mv second.txt final.txt’ command to move the contents from second.txt to
final.txt.

You might also like