Name: Tej. D. Shah Subject:CC-304 Linux Uni. Practical programme College :L.J. College Of Computer Application. Questions:

Similar documents
LOG ON TO LINUX AND LOG OFF

Linux Shell Script. J. K. Mandal

Unix Guide. Meher Krishna Patel. Created on : Octorber, 2017 Last updated : December, More documents are freely available at PythonDSP

Shell. SSE2034: System Software Experiment 3, Fall 2018, Jinkyu Jeong

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

Introduction to the UNIX command line

Unix Introduction to UNIX

CENG 334 Computer Networks. Laboratory I Linux Tutorial

UNIX ASSIGNMENT 1 TYBCA (Sem:V)

Basic Linux (Bash) Commands

Introduction p. 1 Who Should Read This Book? p. 1 What You Need to Know Before Reading This Book p. 2 How This Book Is Organized p.

The Unix Shell & Shell Scripts

Useful Unix Commands Cheat Sheet

On successful completion of the course, the students will be able to attain CO: Experiment linked. 2 to 4. 5 to 8. 9 to 12.

Introduction to Unix: Fundamental Commands

A Brief Introduction to the Linux Shell for Data Science

2) clear :- It clears the terminal screen. Syntax :- clear

Unix/Linux Basics. Cpt S 223, Fall 2007 Copyright: Washington State University

Chapter-3. Introduction to Unix: Fundamental Commands

Basic UNIX Commands BASIC UNIX COMMANDS. 1. cat command. This command is used to create a file in unix. Syntax: $ cat filename

CS 307: UNIX PROGRAMMING ENVIRONMENT KATAS FOR EXAM 1

CS214 Advanced UNIX Lecture 4

Introduction to Linux

Linux & Shell Programming 2014

Chapter 4. Unix Tutorial. Unix Shell

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

Linux Command Line Primer. By: Scott Marshall

UNIX Programming Laboratory. Subject Code: 10MCA17

Part 1: Basic Commands/U3li3es

INd_rasN SOME SHELL SCRIPTING PROGRAMS. 1. Write a shell script to check whether the name passed as first argument is the name of a file or directory.

Basic UNIX Commands BASIC UNIX COMMANDS. 1. cat command. This command is used to create a file in unix. Syntax: $ cat filename

Lecture 02 The Shell and Shell Scripting

Introduction of Linux

Introduction to Linux

Lab Working with Linux Command Line

Self-test Linux/UNIX fundamentals

BIOINFORMATICS POST-DIPLOMA PROGRAM SUBJECT OUTLINE Subject Title: OPERATING SYSTEMS AND PROJECT MANAGEMENT Subject Code: BIF713 Subject Description:

Unix Basics. Systems Programming Concepts

Introduction to Linux (Part I) BUPT/QMUL 2018/03/14

b. Write a shell script to find smallest of three numbers that are read from keyboard. Page 1 07MCA28 Unix Lab Manual:

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

Set 1 MCQ Which command is used to sort the lines of data in a file in reverse order A) sort B) sh C) st D) sort -r

Introduction to Linux. Woo-Yeong Jeong Computer Systems Laboratory Sungkyunkwan University

Unix as a Platform Exercises + Solutions. Course Code: OS 01 UNXPLAT

Introduction to Linux

QUESTION BANK ON UNIX & SHELL PROGRAMMING-502 (CORE PAPER-2)

Introduction: What is Unix?

Basic Linux Commands. Srihari Kalgi M.Tech, CSE (KReSIT), IIT Bombay. May 5, 2009

Operating Systems. Copyleft 2005, Binnur Kurt

Operating Systems 3. Operating Systems. Content. What is an Operating System? What is an Operating System? Resource Abstraction and Sharing

Practical Session 0 Introduction to Linux

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

PART I : MCS-041. (b) Use head and tail in a pipeline to display lines 25 through 75 of a file? $Head 25 file name $Tail 75 File name

CSCI 211 UNIX Lab. Shell Programming. Dr. Jiang Li. Jiang Li, Ph.D. Department of Computer Science

Unix as a Platform Exercises. Course Code: OS-01-UNXPLAT

Computer Systems and Architecture

Linux Essentials. Programming and Data Structures Lab M Tech CS First Year, First Semester

A Brief Introduction to Unix

Lab #12: Shell Scripting

Introduction to UNIX Command Line

Week 2 Lecture 3. Unix

Introduction to UNIX command-line

Linux Operating System Environment Computadors Grau en Ciència i Enginyeria de Dades Q2

Introduction to Linux. Roman Cheplyaka

Introduction to Linux

Introduction to Supercomputing

Introduction to UNIX command-line II

Introduction to Linux

Linux & Shell Programming 2014

Introduction to the Linux Command Line

Shell programming. Introduction to Operating Systems

Linux Essentials Objectives Topics:

CENG393 Computer Networks Labwork 1

The Shell. EOAS Software Carpentry Workshop. September 20th, 2016

CS197U: A Hands on Introduction to Unix

1. What statistic did the wc -l command show? (do man wc to get the answer) A. The number of bytes B. The number of lines C. The number of words

LING 408/508: Computational Techniques for Linguists. Lecture 5

The Unix Shell. Pipes and Filters

3/8/2017. Unix/Linux Introduction. In this part, we introduce. What does an OS do? Examples

Conditional Control Structures. Dr.T.Logeswari

Linux Refresher (1) 310/ Fourth Workshop on Distributed Laboratory Instrumentation Systems (30 October - 24 November 2006)

Week 5 Lesson 5 02/28/18

CS 3410 Intro to Unix, shell commands, etc... (slides from Hussam Abu-Libdeh and David Slater)

EECS 2031E. Software Tools Prof. Mokhtar Aboelaze

Intro to Linux. this will open up a new terminal window for you is super convenient on the computers in the lab

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

First of all, these notes will cover only a small subset of the available commands and utilities, and will cover most of those in a shallow fashion.

Introduction to Linux and Cluster Computing Environments for Bioinformatics

Outline. Structure of a UNIX command

d. 1 e. test: $a: integer expression expected

Read the relevant material in Sobell! If you want to follow along with the examples that follow, and you do, open a Linux terminal.

Lecture 4. Log into Linux Reminder: Homework 1 due today, 4:30pm Homework 2 out, due next Tuesday Project 1 out, due next Thursday Questions?

Bourne Shell Reference

Essential Linux Shell Commands

DAVE LIDDAMENT INTRODUCTION TO BASH

Using UNIX. -rwxr--r-- 1 root sys Sep 5 14:15 good_program

Introduction to the Linux Command Line January Presentation Topics

Software I: Utilities and Internals. What is UNIX?

Introduction to Linux

Answers to Even-numbered Exercises

Transcription:

Name: Tej. D. Shah Subject:CC-304 Linux Uni. Practical programme College :L.J. College Of Computer Application Questions: Q.1 Check the output of the following commands:date, ls, who, cal, ps, wc, cat, uname, pwd, mkdir, rmdir, cd, cp, rm, mv, diff, chmod, grep, sed, head, tail,cut, paste, sort, nd, man Q.2 Write a script to nd the complete path for any le. Q.3 Write a shell script to execute following commands 1. Sort le abc.txt and save this sorted le in xyz.txt 2. Give an example of : To execute commands together without affecting result of each other. 3. How to print this is a three line 1. Text message 4. Which command display version of the UNIX? 5. How would u get online help of cat command? Q.4 Write a shell script to execute following commands 1. How would u display the hidden les? 2. How delete directory with les? 3. How would user can do interactive copying? 4. How would user can do interactive deletion of les? 5. Explain two functionality of mv command with example? Q.5 Write a shell script to execute following commands 1. Create a le called text and store name,age and address in it. 2. Display the contents of the le text on the screen. 3. Delete the directories mydir and newdir at one shot. 4. Sort a numeric le? 5. Change the permissions for the le newtext to 666. Q.6 Write shell script that accept lename and displays last modication time if le exists, otherwise display appropriate message. Q.7 Write a shell script to display the login names that begin with s. Q.8 Write a shell script to remove the zero sized le from the current directory

Q.9 Write a shell script to display the name of all the executable le from the current directory. Q.10 Write a shell script that will display welcome message according to time Q.11 Write a shell script to nd number of ordinary les and directory les. Q.12 Write a shell script that takes a lename from the command line and checks whether the le is an ordinary le or not. 1 If it is an ordinary le it should display the contents of the le. 2.If it is not an ordinary le script should display the message: File does not exist or is not ordinary, cannot display. Q.13 Write a shell script that takes a lename from the user and checks whether it is a directory le or not. 1 If it is a directory, the script should display the contents of the directory. 2.If it is not a directory le script should display the message: File is not a directory le Q.14 Write a shell script that takes a lename as an argument and checks if the le exists and is executable. 1If the le is executable the shell script should display the message: File exists 2 If the le does not exists and is not executable the script should display the message: File does not exist or is not executable. Q.15 Write a shell script that displays all subdirectories in current working directory. Q.16 Write a shell script that calculates the number of ordinary and directory les in your current working directory. Q17 Write a shell script that accepts 2 lenames and checks if both exists; if both exist append the content of the second le into the rst le. Q18 Write a shell script that takes the name of two les as arguments and performs the following: i. Displays the message : Displaying the contents of le :( rst argument) and displays the contents page wise. ii. Copies the contents of the rst argument to second argument. iii. Finally displays the message : File copied successfully. Q19 Write a shell script to display the following menu and acts accordingly: i. Calendar of the current month and year. ii. Display Good Morning/Good Afternoon/Good Evening according to the current login time. iii. User name, Users home directory. iv. Terminal name, Terminal type. v. Machine name. vi. No. of users who are currently logged in; List of users who are currently logged in.

Q.20 Write a shell script that displays the following menu and acts accordingly 1. Concatenates two strings 2. Renames a le 3. Deletes a le. 4. Copy the le to specic location Q.21 Write a shell script to change the sufx of all your *.txt les to.dat. Q.22 Write a shell script to accept a directory-name and display its contents. If input is not given HOME directory's contents should be listed. (Make use of command line argument) Q.23 Write a shell script to get all les of home directory and rename them if their names start with c. Newname = oldname111 Q.24 Write a shell script that takes two lename as arguments. It should check whether the contents of two les are same or not, if they are same second le should be deleted. Q.25 Write a shell script that accepts two directory names from the command line and copies all the les of one directory to another. The script should do the following _ If the source directory does not exist, flash a error message _ If destination directory does not exist create it _ Once both exist copy all the les from source directory to destination directory. Q.26 Write a shell script that displays the following menu _ List home directory _ Date _ Print working directory _ Users logged in Read the proper choice. Execute corresponding command. Check for invalid choice. Q.27 Write a shell script that displays all hidden les in current directory. Q.28 Write a shell script that Combine two les in the third le horizontally and vertically. Q.29 Write a shell script to delete all the spaces from a given le. Q.30 Write a shell script to nd a given date fall on a weekday or a weekend. Q.31 Write a shell script to search for a given word in all the les given as the arguments on the command line. Q.32 Write a shell script that display last modied le in the current directory. Q.33 Write a script to display the permissions of the particular le.

Q.34 Write a shell script to display the calendar in the following manner: i. Display the calendar of months m1 and m2 by CAL m1, m2 command le. ii. Display the calendar of the months from m1 to m2 by CAL m1-m2 command le. Q.35 Write a shell script to display the following menu for a particular le : i. Display all the words of a le in ascending order. ii. Display a le in descending order. iii. Toggle all the characters in the le. iv. Display type of the le. Q.36 Write a shell script to check whether the named user is currently logged in or not. Q.37 Write a shell script to display the following menu for a particular le: i.display all the words of a le in ascending order. ii.display a le in descending order. iii.display a le in reerse order. iv.toggle all the characters in the le v.display type of the le. Q.38 Write a shell script to nd total no. Of users and nds out how many of them are currently logged in. Q.39 Write a shell script that displays the directory information in the following format- Filename Size Date Protection Owner Q.40 Write a shell script to display ve largest les from the current directory Q.41 Write a shell script that toggles contents of the le Q.42 Write a shell script that report whether your friend has currently logged in or not. If he has logged in the shell script should send a message to his terminal suggesting a dinner tonight. If you do have write permission to his terminal or if he hasn t logged in such a message should be mailed to him about your dinner proposal. Q.43 Write a shell script for the performing the write and mail. Q.44 Write a shell script to accept any character using command line and list all the les starting with that character in the current directory. Q.45 Create a le called student containing roll-no, name and marks. a. Display the contents of the le sorted by marks in descending order b. Display the names of students in alphabetical order ignoring the case. c. Display students according to their roll nos. d. Sort le according to the second eld and save it to le names. e. Display the list of students who scored between 70 and 80. Note: Shell Script based on Files and lters should only to be asked in exam

Q.1 Check the output of the following commands:date, ls, who, cal, ps, wc, cat, uname, pwd, mkdir, rmdir, cd, cp, rm, mv, diff, chmod, grep, sed, head, tail,cut, paste, sort, nd, man Output:- abc@xyz-virtualbox:~$ date Thu Sep 4 11:38:40 IST 2014 abc@xyz-virtualbox:~$ ls Desktop Downloads Music Public Videos Documents examples.desktop Pictures Templates abc@xyz-virtualbox:~$ who xyz :0 2014-09-04 11:30 (:0) xyz pts/1 2014-09-04 11:38 (:0) abc@xyz-virtualbox:~$ cal September 2014 Su Mo Tu We Th Fr Sa 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 abc@xyz-virtualbox:~$ ps PID TTY TIME CMD 2598 pts/1 00:00:00 bash 2886 pts/1 00:00:00 ps abc@xyz-virtualbox:~$ ls wc 9 9 84 abc@xyz-virtualbox:~$ cat le1 Hello abc@xyz-virtualbox:~$ uname Linux abc@xyz-virtualbox:~$ pwd /home/xyz abc@xyz-virtualbox:~$ mkdir abc

abc@xyz-virtualbox:~$ rmdir abc abc@xyz-virtualbox:~$ cd Desktop abc@xyz-virtualbox:~$ cp le1 le2 abc@xyz-virtualbox:~$ mv le2 le3 abc@xyz-virtualbox:~$ grep * grep: Documents: Is a directory grep: Downloads: Is a directory examples.desktop:[desktop Entry] grep: Music: Is a directory grep: Pictures: Is a directory grep: Public: Is a directory grep: Templates: Is a directory grep: Videos: Is a directory abc@xyz-virtualbox:~$ head -5 le1 Hello hi sad sadnslad sadsad abc@xyz-virtualbox:~$ tail -2 le1 x zc abc@xyz-virtualbox:~$ cat le1 cut -d":" -f1 RollNO 1 2 3 abc@xyz-virtualbox:~$ sort le1 1 : xyz 2 : abc 3 : pqr RollNO :Name

abc@xyz-virtualbox:~$ paste le1 -d":" le3 RollNO:Name:Hello 1 : xyz: 2 : abc: 3 : pqr: Q.2 Write a script to nd the complete path for any le. echo "Enter name of le to nd the full path" read x readlink -f $x Q.3 Write a shell script to execute following commands 1. Sort le abc.txt and save this sorted le in xyz.txt 2. Give an example of : To execute commands together without affecting result of each other. 3. How to print this is a three line 1. Text message 4. Which command display version of the UNIX? 5. How would u get online help of cat command? select= until [ "$select" = "6" ]; do echo PROGRAM MENU echo 1 Sort le abc.txt and save this sorted le in xyz.txt echo 2 Give an example of:to execute commands together without affecting result of each other echo 3 How to print "this is a three -line Text message" echo 4 Which command display version of the UNIX? echo 5 How would u get online help of cat command echo 6 Exit echo Enter choice case $a in 1) echo File abc before sorting cat abc.txt echo File xyz after sorting sort abc.txt cat > xyz.txt

cat xyz.txt read x 2) echo Hi;cat le1 read y 3) printf "this is \na three -line\ntext message\n" read z read j 4) uname --version read e 5) echo man cat read f 6) exit ;; *) echo Please enter valid option read h esac done Q.4 Write a shell script to execute following commands 1. How would u display the hidden les? 2. How delete directory with les? 3. How would user can do interactive copying? 4. How would user can do interactive deletion of les? 5. Explain two functionality of mv command with example? select= until [ "$select" = "6" ]; do echo PROGRAM MENU echo 1 How would u display the hidden les? echo 2 How to delete directory with les? echo 3 How would user can do interactive copying? echo 4 How would user can do interactive deletion of les? echo 5 Expalin two functionalities of "mv" command with example? echo 6 Exit echo Enter choice

case $a in 1) ls -a read x 2) rm -r abc echo Directory with les removed read y 3) cp -i le4 le6 echo File1 copied to File2 read j 4) rm -i le4 le6 echo Both les removed read e 5) mv le5 le6 echo Renamed le5 as le6 read f mv Desktop Pictures read g 6) exit ;; *) echo Please enter valid option read h esac done Q.5 Write a shell script to execute following commands 1. Create a le called text and store name,age and address in it. 2. Display the contents of the le text on the screen. 3. Delete the directories mydir and newdir at one shot. 4. Sort a numeric le? 5. Change the permissions for the le newtext to 666. select= until [ "$select" = "6" ]; do echo PROGRAM MENU

echo 1 Create a le called text and store name,age and address in it. echo 2 Display the contents of the le text on the screen echo 3 Delete the directories mydir and newdir at one shot echo 4 Sort a numeric le? echo 5 Change the permissions for the le newtext to 666 echo 6 Exit echo Enter choice case $a in 1) echo Enter name,age and Address read name ge read Address (echo $name;echo $age;echo $Address) cat >> text.txt read g 2) cat text.txt read h 3) mkdir mydir;mkdir newdir echo Directories Created ls echo Directories removed rmdir mydir;rmdir newdir ls read j 4) sort -n no.txt read e 5) echo "This is new le" cat >> newtext chmod 666 newtext read g 6) exit ;; *) echo Please enter valid option read h esac done

Q.6 Write shell script that accept lename and displays last modication time if le exists, otherwise display appropriate message. echo PL enter lename if test -e $a ls -lt $a else echo File does not exist Q.7 Write a shell script to display the login names that begin with s. who grep s* Q.8 Write a shell script to remove the zero sized le from the current directory nd -size 0c -delete Q.9 Write a shell script to display the name of all the executable le from the current directory. nd -type f -executable -print Q.10 Write a shell script that will display welcome message according to time a="$(date +'%H')" if test $a -lt 12 echo Good Morning if test $a -gt 12 -a $a -lt 16 echo Good Afternoon if test $a -gt 16 -a $a -lt 20 echo Good Evening

if test $a -gt 20 echo Good Night Q.11 Write a shell script to nd number of ordinary les and directory les. echo Number of Ordinary les nd -type f wc -l echo Number of Directory les nd -type d wc -l Q.12 Write a shell script that takes a lename from the command line and checks whether the le is an ordinary le or not. 1 If it is an ordinary le it should display the contents of the le. 2.If it is not an ordinary le script should display the message: File does not exist or is not ordinary, cannot display. if test -f $1 echo $1 is Ordinary le echo $1 cat $1 else echo File is Directory Q.13 Write a shell script that takes a lename from the user and checks whether it is a directory le or not. 1 If it is a directory, the script should display the contents of the directory. 2.If it is not a directory le script should display the message: File is not a directory le echo Pl enter lename if test -d $a echo $a is Directory echo $a Contents

ls -l $a else echo File is not a Directory Q.14 Write a shell script that takes a lename as an argument and checks if the le exists and is executable. 1If the le is executable the shell script should display the message: File exists 2 If the le does not exists and is not executable the script should display the message: File does not exist or is not executable. if test -e $1 echo $1 exist else echo $1 does not exists if test -x $1 echo $1 is executable else echo $1 is not executable Q.15 Write a shell script that displays all subdirectories in current working directory. Output:- nd -type d Q.16 Write a shell script that calculates the number of ordinary and directory les in your current working directory. echo Number of Ordinary les nd -type f wc -l echo Number of Directory les nd -type d wc -l Q17 Write a shell script that accepts 2 lenames and checks if both exists; if both exist append the content of the second le into the rst le. echo PL enter rst lename

echo PL enter second lename read b if test -e $a -a -e $b cat $b >> $a Q18 Write a shell script that takes the name of two les as arguments and performs the following: i. Displays the message : Displaying the contents of le :( rst argument) and displays the contents page wise. ii. Copies the contents of the rst argument to second argument. iii. Finally displays the message : File copied successfully. echo Displaying the contents of rst argument page wise cat $1 more echo Copy the contents of rst argument to second argument read b cp $1 $2 echo File Copied Succesfully Q19 Write a shell script to display the following menu and acts accordingly: i. Calendar of the current month and year. ii. Display Good Morning/Good Afternoon/Good Evening according to the current login time. iii. User name, Users home directory. iv. Terminal name, Terminal type. v. Machine name. vi. No. of users who are currently logged in; List of users who are currently logged in. select= until [ "$select" = "7" ]; do echo PROGRAM MENU echo 1 Calendar of the current month and year echo 2 Display Good Morning/Good Afternoon/Good Evening according to the current login time. echo 3 User name,users home directory echo 4 Terminal name,terminal type echo 5 Machine name

echo 6 No of users who are currently logged in;list of users who are currenly logged in. echo 7 Exit echo Enter choice case $a in 1) cal read z 2) a="$(date +'%H')" if test $a -lt 12 echo Good Morning if test $a -gt 12 -a $a -lt 16 echo Good Afternoon if test $a -gt 16 -a $a -lt 20 echo Good Evening if test $a -gt 20 echo Good Night read x 3) echo Username;logname echo User Home directory;$home read c 4) echo "Terminalname" $SHELl echo Terminaltype tty read v 5) echo Machine name uname read b 6) echo List of users who are currently logged in who -q tail -1

read n 7) exit;; *) echo Please enter valid option read h esac done Q.20 Write a shell script that displays the following menu and acts accordingly 1. Concatenates two strings 2. Renames a le 3. Deletes a le. 4. Copy the le to specic location select= until [ "$select" = "5" ]; do echo PROGRAM MENU echo 1 Concatenates two strings echo 2 Renames a le echo 3 Deletes a le echo 4 Copy a le to specic location echo 5 Exit echo Enter choice case $a in 1) echo Enter string 1 echo Enter string 2 read b c=$a" "$b echo Concatenated Strin is $c read z 2) echo Renames a le mv le6 le7 echo File 6 renamed File7 successfully read g 3) echo Deletes a le rm le2 echo File2 removed successfully read j

4) echo Copy the le to specic location cp text.txt /home/xyz/downloads/xyz echo File text.txt succesfully Copied to xyz read v 5) exit;; *) echo Please enter valid option read h esac done Q.21 Write a shell script to change the sufx of all your *.txt les to.dat. echo Change Sufx of all your *.txt les to.dat for f in *.dat; do leftname=`basename $f dat` mv $f ${leftname}txt done Q.22 Write a shell script to accept a directory-name and display its contents. If input is not given HOME directory's contents should be listed. (Make use of command line argument) if test -d $1 ls $1 else ls $HOME Q.23 Write a shell script to get all les of home directory and rename them if their names start with c. Newname = oldname111 for f in c*; do mv $f r

done Q.24 Write a shell script that takes two lename as arguments. It should check whether the contents of two les are same or not, if they are same second le should be deleted. if test -e $1 -a -e $2 same=`diff $1 $2` if test -z $same rm $2 echo File 2 removed because contents of both the les were same else echo Both les are not same else echo File does not exist Q.25 Write a shell script that accepts two directory names from the command line and copies all the les of one directory to another. The script should do the following _ If the source directory does not exist, flash a error message _ If destination directory does not exist create it _ Once both exist copy all the les from source directory to destination directory. if test -d $1 echo Source Directory exists if test -d $2 cd $1 cp *.* $2\ else

mkdir $2 cd $1 cp *.* $2\ else echo Source Directory does not exist Q.26 Write a shell script that displays the following menu _ List home directory _ Date _ Print working directory _ Users logged in Read the proper choice. Execute corresponding command. Check for invalid choice. select= until [ "$select" = "5" ]; do echo PROGRAM MENU echo 1 List home directory echo 2 Date echo 3 Print working directory echo 4 Users logged in echo 5 Exit echo Enter choice case $a in 1) ls ~ read z 2) date read g 3) pwd read j 4) who read v 5) exit;; *) echo Please enter valid option read h

esac done Q.27 Write a shell script that displays all hidden les in current directory. ls -a Q.28 Write a shell script that Combine two les in the third le horizontally and vertically. select= until [ "$select" = "3" ]; do echo PROGRAM MENU echo 1 Vertically echo 2 Horizontally echo 3 Exit echo Enter choice case $a in 1) cat $1 > le9 cat $2 >> le9 read z 2) paste $1 $2 >> test2 read g 3) exit;; *) echo Please enter valid option read h esac done Q.29 Write a shell script to delete all the spaces from a given le. cat $1 tr -d " \t"

Q.31 Write a shell script to search for a given word in all the les given as the arguments on the command line. echo Enter the search word for i in $* do if test $a = $i echo Word $a Found on the command line argument done Q.32 Write a shell script that display last modied le in the current directory. ls -lt head -2 tail -1 cut -c 32-50 Q.33 Write a script to display the permissions of the particular le. ls -l $1 more cut -c 1-11,42-46 Q.36 Write a shell script to check whether the named user is currently logged in or not. echo Pl enter user name to check if user is currently logged-in b=`who cut -c 1-5 head -1` if test $a = $b echo User is logged-in else echo User is not logged-in Q.38 Write a shell script to nd total no. Of users and nds out how many of them are currently logged in. tot=`cat /etc/passwd wc -l` cur=`who wc -l`

echo Total users $tot echo Currently logged in users $cur Q.40 Write a shell script to display ve largest les from the current directory du -a sort -n -r head -5 ls -lsh head -6 tail -5 Q.42 Write a shell script that report whether your friend has currently logged in or not. If he has logged in the shell script should send a message to his terminal suggesting a dinner tonight. If you do have write permission to his terminal or if he hasn t logged in such a message should be mailed to him about your dinner proposal. echo Pl enter user name to check if user is currently logged-in b=`who cut -c 1-5 head -1` if test $a!= $b echo User is not logged-in else echo User is not logged-in talk $a"dinner tonight at my place" Q.44 Write a shell script to accept any character using command line and list all the les starting with that character in the current directory. ls -lt $1* Note: 30,34,35,37,39,41,43,45 Shell scripts are not there!