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

Unix Lab QUESTION SET

Uploaded by

Chola Raja K
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

Unix Lab QUESTION SET

Uploaded by

Chola Raja K
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

KARPAGAM COLLEGE OF ENGINEERING

(Autonomous)
COIMBATORE-32.
AUTONOMOUS ARREAR PRACTICAL EXAMINATIONS-NOVEMBER 2016

BRANCH / SECTION: B.E CSE ‘A’ & ‘B’ MAX.MARKS:100

SUBJECT CODE / SUBJECT NAME: /UNIX AND SHELL PROGRAMMING LABORATORY

DATE / SESSION:9.11.16 / AN TIME: 3 HRS

1. Peroform all excercises


1. You can create your own directories. To make a directory, say mystuff, type the following command in the
Terminal window.
2. To make mystuff your current working directory
3. create a new directory called M
4. copies f1 to f2 (without using cp)
5. Print only the first 3 lines of the file.
6. Print only the last 3 lines of the file
7. Delete all blank lines
8. Display Hidden Files.
9. Remove the Directory M with confirmation.
10. Remove the the files f1 and f2
2 . Perform all exercises:
1.Create a file called “ file1.txt”
2.And the contents in the file should be given below

3.Highlight only the text “unix” (case sensitive) in the file.


4.Display the block number of the line which contains the pattern “UNIX”
5.Count the number of lines which contains “unix” in the file (case sensitive)
6.Count the number of lines which contains “unix” in the file (not a case sensitive)
7.Find out the occurences of the letter 'x' in the file 'file1.txt'
3. Write a shell script to reverse the contents of a file, remove the file, display the file modes.
4. Create a file and check the file is created or not and raise the appropriate message. Display the
created file using system call.

1. Perform all exercises


1. Create two directories, one called yourfirstname (by this I don't mean to name it with the string
"yourfirstname" but rather to use your real first name, like "archie", or "betty"), the other called yourlastname;
2. create files named q1, q2, q3, q4, q5 and q6 inside yourfirstname.
3. List all the created files alone.
4. Write some content into the file q1 and q2.
5. Check how many words and lines are present in the file q1.
6. Remove the Directory with files without using rmdir command.
7. Display File Inode Number
8. Hide Control Characters
9. How do you see command line history in UNIX?
2. Perform all exercises:
1. Create a file with the contents
2. Display only details of Male candidates.
3. Create Address details of the above candidattes in the file named as “candidate.txt”
4. Display the details of “Meena” in both files
5. Count the Female strength of the file
6. Deleting the line who are “CSE” student
7. Display the line numbers containing the pattern for only the Male candidates
3. Write a shell script to guess a number between 1 to 10 ,if it match print success.
4. Create 5 files and change the modes of the created files using system calls and display the file
details before and after the changes of the file.
1. Perform all exercises:
1. Go to parent directory and go to your home directory .
2. copy file1 with new name file2
3. rename file1 as file2, or move file1 to new location file2
4. short for catenate (concatenate) - copies the standard input to the standard output
5. Give numbering to all the lines in a file.
6. Find out your present working directory.

7. List all files in the current directory.


8. Find Files Based on file-type.
9. Find the files which are accessed in last one hour.
2. Perform all exercises:
1. Create a file “emp.lst” which contains below text
2476|anil aggarwal|manager|sales|5000
3564|sudhir agarwal |executive|personnel|7500
0110|v.k.agrawal|g.m|marketting|9000
2. Display the three agrwals by using grep woithout using i option
3. display all agarwal with using i options
4. Display the First occurence of “r” emp.lst
5. Deleting the line who belongs to “ personnel” that results redirect to another file
6. Command to find the non blank lines
7. Find only the lines that have unix OR Linux using fgrep
3. Write a script that uses a until loop to display the numbers zero to Hundred.
4. Create2 files namely “f1.txt” & “f2.txt”. Create a copy of those files using system call and
display the created files.

1. Perform all Exercises:


1. Go into the subdirectory called "unix".
2. Copy the file "f1.txt" into "f1.txt.copy".
3. Rename the file "f1txt.copy" to "f2".
4. Move the file "f2" into the "data" subdirectory.
5. Create a new subdirectory called "new" in the unix directory.
6. Move the file "f2" in the "data" directory into the "new" directory.
7. Move the file "f2" in the "new" directory back into the "unix" directory and change the name to "f1.old".
8. Delete the file "f1.old".
9. Remove the "new" subdirectory.
2. Perform all exercises:
1. Create a file “demo.txt” and then write the following contents :
THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE.
this line is the 1st lower case line in this file.
This Line Has All Its First Character Of The Word With Upper Case.
Two lines above this line is empty.
And this is the last line.
2. Write a command to check for full words, not for sub-strings using grep -w command.
3. Write a command to display 2 lines after match has been found by using grep command
4. Write a command to display 3 lines before match has been found by using grep command
5. Write a command to display 2 lines around the match has been found by using grep
6. Write a by using Grep NOT using grep -v?
7. Command to find the non blank lines.
3. Write a shell script to get input from command line argument and check age limit for senior
citizen.
4. Create two files namely “f1.txt” & “f2.txt”. Write the content “UNIX PROGRAM” in to the
file “f1.txt”. Read the content from the file “f1.txt” and write it into “f2.txt” using system
call.
1. Perform all Exercises:
1. Copy all files in the "unix" directory into the "text" subdirectory.
2. Make a list of your files into a file.
3. Write a single command that shows how many files you have in your current working directory.
4. Find out who is logged on
5. Displays the username, line, and time of all currently logged-in sessions, but only for the terminal session
where the command was issued.
6. List all files created or changed during the last 24 hours.
7. Create two different files under current directory and write the contents into those files by using cat command.
8. Use a command, which is used to find the differences between the contents of two different files by using diff
command.
9. Use a command ,which is used to sort two different files and then compare two different sorted files by using
comm and sort command.
2. Perform all Exercises:
1. Create a file “demo.txt” and then write the following contents :
THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE.
this line is the 1st lower case line in this file.
This Line Has All Its First Character Of The Word With Upper Case.
Two lines above this line is empty.
And this is the last line.
2. Search for two patterns in grep.
3. Write a grep command to Case insensitive search?
4. Write a fgrep command to Counting the number of matches?
5. Write a command which is used to invert the pattern match (shows the lines that are not matched with the
pattern string).
6. Write a command which is used to count the number of matches.
7. Write a command which is used to shows line number while displaying the output.
3. Write a shell script to find out the factorial of the given number.
4. Create a file “unix.txt” and write some content into the file. Create a softlink of the file
“unix.txt” and display the inode number using system call.

1. Perform all Exercises:


1. Write a command to Copy an existing file in your current directory to another file in the current directory and
then list your directory.
2. Use the copy command with the "inquire"(overwrite) option .
3. Make two new directories, subdir1 and subdir4. Use the recursive option to copy an entire subdirectory to a
new subdirectory and then list both directories
4. Use the copy command that accepts "wildcard" characters and then list the subdir1 subdirectory to find out.
5. Write a command, which is used to rename directories and then list your files.
6. Write a command, which is used to move newtest3 into a new location, then list your files.
7. Write a command, which is used to move directories Use the command to move dir4 and subdir1 to unixlab1,
then list your files in your ADM directory.
8. Write a command, which is used to describe the action of wildcard characters and list your files.
9. Write a command to change directory to unixlab1, then use the rm command to delete a file. List your
directory after the command completes.
2. Perform all exercises:
1. Consider a file, school.txt, with the following content :

2. Print only the XI standard students.


3. Delete the lines from 3 to 5
4. Quits after line number 4
5. Display only the last line of the file.
6. Display the line 1,2 and 5,6 from the file.
7. Write the XII students alone to the file cpyschool.txt
8. Insert column name for each column for the above file.(ex:- ID,Name,Class,Marks)
9. Substitute ID instead of A for all student's roll number.
10. Append line number to all the lines to the file.
3. Write Shell script to find out biggest number from given three nos. Numbers are supplied as
command line arguments. Print error if sufficient.
4. Create a file “linux.txt” and write some content into the file. Create a hardlink of the file
“linux.txt” and display the inode number and remove the link using system call.

1. Perform all Exercises:


1. Write a command which is used to directly compare the content of two different files
2. Write a command which is used to skip some initial bytes of input files and then start the comparison
3. Write a command which is used to get the version informations by using cmp command.
4. Write a command to convert the decimal number 128 to hexadecimal number .
5. Write a command to convert the hexadecimal number A to decimal number .
6. Perform all the Arithemetic calculations with the help of bc command.
7. Command to remove a file from the particular directory.
8. Command to remove a directory.
9. Command to change the name of the file.
10. Command which is used to create the duplicate of the files.
2. Perform all exercises:
1. Create a file “f1.txt” and include some contents in to the file.
THIS LINE IS THE 1ST UPPER CASE LINE IN THIS FILE.
this line is the 1st lower case line in this file.
This Line Has All Its First Character Of The Word With Upper Case.
Two lines above this line is empty.
And this is the last line.
2. Substitute “is” as “was” using unix command.
3. Find two patterns “THE” and “THIS” in the file.
4. Delete only the 2 and 4th line from the file.
5. Print only the 6th line from file.
6. Print 3rd line and delete 2nd line from the file.
7. Quit after 3rd line from the file.
3. Write a UNIX shell script with a simple elif that to check age limit.
4. Create a file “linux.txt” and write some content into the file. Create a hardlink of the file
“linux.txt” and display the inode number using system call.

1. Perform all the operations with the help of the below given diagram.
1. Create a directory and sub directory for the below given tree structure.

2. Write a command which is used to list all the files in your home directory by using ls command.
3. Write a command to change directory to the subdir1 subdirectory. List the directory to view its contents. Then
use the "*" wildcard to remove all of the files.
4. Write a command to get out of the subdir1 subdirectory by using the command cd .. Now try to use rm to
remove a directory.
5. To view the name of the current directory
6. To display all the files including hidden files
7. To display all the files with its inode number
8. To display all the files including files in subdirectories.
9. To create a directory called stud.change the stud.directory
10. To verify whether you have actually changed to the stud diectory,return to your original directory.
2. Perform all exercises:
1. Consider a file, employee.txt, with the following content :

2. Duplicate first two lines alone from the file.


3. Delete the last line from the file by using script file.
4. Display the line 2 and delete the line 4 from the file.
5. Print only the marketing department employees.
6. Write the sales department employee detail to another file.
7. Insert the Footer for file “Employee details”.
8. Append a new record in to the file.
9. Substitute gm as “general manager” in the file.
10. Display the Employee id as ID & Id number (ex:ID & 2233)
11. Display the first 3lines using q option
3. Write a shell script to perform operations like Count char,words and lines of file, display file in
reverse, change case and frequency of a particular word in file.
4. Create a file “linux.txt” and write some content into the file. Create a softlink of the file
“linux.txt” and display the inode number and remove the link using system call.

1. Perform all Exercises:


1. To redirect the system calender contents to the file a1
2. To move the contents of the command a1 to a new file by using redirection operator.
3. List the file starting with 'a'
4. To find the file names ending with “1”
5. To find the file starting with “vignesh” and then followed by any one character and with any extension of one
character
6. To display the date as mm/dd/yy
7. To display the time as HH:MM:SS(A.M/P.M)
8. To display the current day in abbreviated form
9. To display the calender may 2009
10. To display the complete name of the terminal
11. To display about your operating system
2. Perform all exercises:
Consider a file, school.txt, with the following content :

1. Duplicate first two lines alone from the file.


2. Delete the last line from the file by using script file.
3. Display the line 2 and delete the line 4 from the file.
4. Print only the marketing department employees.
5. Write the sales department employee detail to another file.
6. Insert the Footer for file “Employee details”.
7. Append a new record in to the file.
8. Substitute gm as “general manager” in the file.
9. Display the Employee id as ID & Id number (ex:ID & 2233)
10. Display the first 3lines using q option
3. Write shell Script to reads text file and perform below operations.
1) Count character,words and lines
2) Display content in reverse
3) Count particular word
4) Convert upper to lower
5) Convert lower to upper
4. Mr.Karun was searching for a job for two years since he completed his B.E. As he registered in
linked-in .He was called for an interview in Infosys. By his continuous work he got selected in
all upcoming rounds and received call letter. He was supposed to create a file and enter his
complete details for company reference. Identify hidden system call and implement c program
using that system calls.

1. Perform all Exercises:


1. You can create an entire directory tree all at once. The example will create the following diretcory tree.

2. Write a unix command to display only the date part and ignore the time part?
3. Write a unix command to display only the time part and ignore the date part?
4. The input file contains the below text
cat filenames.txt
logfile.dat
sum.pl
add_int.sh
5. First reverse the text in each line and then apply the command on it.
6. How to find out the difference two files.
7. Demonstration of cat command usage by considering the below text file as an example
Quote.txt :
Stars can't shine without darkness..
psychopathy is the only useful craziness.
See you on my next dream.....
8. Write a unix command to display contents of a file
9. Write a unix command to display the contents in numbering order.
10. Write a unix command to display "$" at end of each line
2. Perform all exercises:
A201 Ashwin 3500 Sales
A202 Barathi 4000 Production
A203 Chitra 4500 Manager
A204 Devi 5000 MD
1. Append a new record at the end of the file.
2. Substitute “Sales” as “Production”.
3. Print only the production employee details.
4. Display A102 as A102ID.
5. Display first 2 lines and quit.
6. Delete the line 4 from the file.
7. Insert a header in to the file.
8. Write the MD details to another file.
9. Display MD and Manager details alone.
3. Write a Shell Script to find whether number is positive,negative or zero
4. Mr.John was worked in a small company and earned less salary for a month. He was not
satisfied with his salary which meets only his daily living. One day he dreamed like building a new house with his
earning. He worked day and night, for his dream and finally he built a new house. He kept house warming function and
invited all his friends and family for this function added with chief guest as his school teacher. His teacher gifted a
written bless note for newly created home. All guests read the note and felt happy. Identify hidden system call and
implement c program using that system calls.

1. Perform all Exercises:


1. Demonstration of head command usage by considering the below text file as an example
Quote.txt :
Stars can't shine without darkness..
psychopathy is the only useful craziness.
See you on my next dream.....
2. Write a unix command to suppress repeated empty output lines
3. Write a unix command to display TAB characters as ^I.
4. Write a unix command to displaya help message and exit.
5. Write a unix command to display output version information and exit.
6. Write a unix command to print first 5 bytes from input file.
7. Write a unix command to print first 5 lines from input file.
8. Write a unix head command to Prevent printing of header information that contains file name
9. Write a unix/linux head command to displays help message and exit.
2. Perform all exercises: Consider a file, details.txt with the following content (Rno,Name,Course,Maths,Sci,CS)
1. Count the number of students whose roll numbers are less than 104
2. Count the number of science students.
3. Store the science students details in a script file.
4. Print all student details except commerce stduents.
5. Print all the details who scored below 50 in Mathematics.
6. Count Number of students having total >=250
7. Print the entire file without specifying any column name or special variable.
8. Count total strength in all courses of above file.
3. Write a Shell Script to reverse a number.
4. Mr.Sam working in L&T .Sam is senior marketing manager he got new project, regarding that
he have to discusses with his team mates. He want to share the information his team members.
But they had separate whatsapp group (Tricky Brain Group) to share detail about project
instantly. Identify the kind of communication and implementing using C Programming.
1. Perform all Exercises:
Demonstration of tail command usage by considering the below text file as an example
Quote.txt :
Stars can't shine without darkness..
psychopathy is the only useful craziness.
See you on my next dream.....
1. Write a unix command to print last 4 bytes from input file.
2. Write a unix command to print last 4 lines from input file.
3. Write a unix tail command to Prevent printing of header information that contains file name
4. Write a unix tail command to to print header information always
5. Write a unix tail command to sleep for 5 seconds between iterations
6. Write a unix tail command to print appended data as and when the file grows .
7. Write a unix sort command to display contents ignore leading blanks.
8. Write a unix command to use case insensitive sorting.
9. Write a unix sort command to Sort based on months. Considers only first 3 letters as month. Eg: JAN, FEB
2. Perform all exercises:
Consider a file stock.lst with the following content,

1. Display only the garment details


2. Display the electronic items name,Rate and quantity
3. Print all items whose quantity is greater than or equal to 10
4. Find the length of the all lines in the stock.lst file
5. Print the Total Item count in stock
6. Display the first occurrence of a character “c” in the string “stock”
7. Generate random numbers between 0-1
8. Print only the code of garment items
3. Write a Shell Script to print Armstrong numbers from 1 to 1000.
4. In MKP college of Engineering, Operating System subject was handled by OS Team for EEE,
EIE. They prepared hand notes for all units .At the time of End Sem Exam they passed notes to respective class
through google groups (EEEscaro, EIEcoss).Identify the kind of communication and implement using C
Programming.

1. Perform all Exercises:


1. You can create an entire directory tree all at once. The example will create the following diretcory tree.
2. Write a unix command for numeric sorting
3. Write a unix command for Reverse order sorting
4. Write a unix sort command that Suppresses duplicate lines
5. Write a unix command natural sort of numbers within text
6. Write a unix uniq command to Count of occurrence of each line.
7. Write a unix command to Prints only duplicate lines.
8. Demonstration of cat command usage by considering the below text file as an example
new.txt :
if( 2 ge 3) {
print "greater\n";
}else {
print "lesser\n";
}
9. Write a unix command to display contents of a file in reverse.
10. Write a unix command to display contents of a file
11. Write a unix cat command to display the contents in numbering order.
12. Write a unix command to display "$" at end of each line
2. Perform all exercises:
Ashwin 150 A1+ve
Ananth 175 B +ve
Balu 160 A +ve
Chitra 180 A-ve
Devi 120 A -ve

Assume that the Sugar level and blood groups are given for the patients.
1. Display only the A1+VE details
2. Print whose sugar count is greater than or equal to 150
3. Find the length of the all lines in the given file
4. Print the Total Patient count
5. Display the first occurrence of a character “c” in the string “stock”
6. Generate random numbers between 0-1
7. Print only the blood group name of “balu” items
3. Write script to print given numbers sum of all digit, For eg. If no is 123 it's sum of all digit
will be 1+2+3 = 6.Get input through command line arugument.
4. In a celebration party, guests are warmly invited with their own dress code. Mr.Alois Army
general of germany and his daughter Eva Braun are invited to that party and requested to be in
their traditional dress code. Guests came with their family members to felicitate the party. These celebrity were
welcomed by red carpet and Mr.Alois requested her daughter to present a memento to all celebrity. Identify the hidden
concept with necessary system call and explain using c program.

1. Perform all Exercises:


1. Write a unix command to display TAB characters as ^I.
2. Write a unix cat command to displays help message and exit.
3. Write a unix cat command to display output version information and exit.
4. Write a unix command to split n files with n number of lines each file.
5. Write a unix command to split n files with n bytes each file.
6. Write a unix split command to n Number of Split Chunks
7. Write a unix xargs command to echo the given text?
8. Write a unix xargs command to Specify Delimiter
9. Write a unix xargs command to Limit Output Per Line.
2. Perform all exercises:
1.Create a file called “ file1.txt”
2.And the contents in the file should be given below

3.Highlight only the text “unix” (case sensitive) in the file.


4.Display the block number of the line which contains the pattern “UNIX”
5.Count the number of lines which contains “unix” in the file (case sensitive)
6.Count the number of lines which contains “unix” in the file (not a case sensitive)
7.Find out the occurences of the letter 'x' in the file 'file1.txt'
3. Write a shell script to print multiplication table of given number where i = 1,2 ... 10 is multiply
by given n (here command line argument 7) in order to produce multiplication table.
4. In technology development, delivering some information to their know person has been done
with text message, after launching new applications in new gadgets such as whatsapp, hike, viber and so on replaced the
text messaging by MMS,Voice message,Video chat. Since these advance applications are developed with the base of
text message. Identify the hidden concept and implement using c program.

1. Perform all Exercises:

1. Write command to move content of file to another new file without options
Use options to satisfy the following constraints
2. Backup a file but does not accept an argument.
3. Move a file that do not prompt before overwriting
4. Move a file that prompt before overwriting
5. Move a file contents to new file do not overwrite an existing file
6. Remove file and ignore nonexistent files, never prompt
7. Remove file and prompt before every removal
8. Remove file and prompt once before removing more than three files, or when removing recursively.
9. Write a unix xargs command to echo the given text?
10. Write a unix xargs command to Specify Delimiter
2. Perform all exercises:
1. Create a file with the below contents

2. Display only details of Male candidates


3. Create Address details of the above candidattes in the file named as “candidate.txt”
4. Display the details of “Meena” in both files
5. Count the Female strength of the file
6. Deleting the line who are “CSE” student
7. Display the line numbers containing the pattern for only the Male candidates
3. Write script to print contains of file from given line number to next given number of lines. For
e.g. If we called this script as Q13 and run as $ sh 17.sh 5 5 sample.txt , Here print contains of
'myf' file from line number 5 to next 5 line of that file.
4. Little Laura was pampered child of Nicolas. On 16th birthday of his daughter, Nicolas has
presented a cute little puppy as his gift. She named it as Solomon. Very soon Solomon become closed to the both father
and daughter and she used to spend lot of time by playing with Solomon. Few years later,she got married and left the
puppy with his father. Now solomon and nicholas staying alone at his home. Identify the hidden concept and execute
using c program.

INTERNAL EXAMINER EXTERNAL EXAMINER

You might also like