Vous êtes sur la page 1sur 36

ASSIGNMENT 1

Submitted to
Mr.Shine K George
Department of MCA

Submitted by
Vinaya Augustine
4A Rollno : 27

ASSIGNMENT 2

Submitted to
Mr.Shine K George
Department of MCA

Submitted by
Vinaya Augustine
4A Rollno : 27

SESSION 1
1. Create three directories named Exam1, Exam2 and Exam3 under your home
directory
-bash-3.2$ mkdir exam1
-bash-3.2$ mkdir exam2
-bash-3.2$ mkdir exam3
2. Move to directory Exam1.
-bash-3.2$ cd exam1
3.Create two directories named Exam11 and Exam12 under the Exam1 directory
-bash-3.2$ mkdir Exam11 Exam12
4. Move to directory Exam2 using only one command (directly from Exam).
-bash-3.2$ cd /home/12amca29/Exam2
-bash-3.2$ pwd
/home/12amca29/Exam2
5. Create three directories called Exam21, Exam22 and Exam23 under the directory
Exam2 (use only one command)
-bash-3.2$ mkdir Exam21 Exam22 Exam23
6. Create a directory called Exam31 under the Exam3 directory without moving
from the Exam2 directory.
-bash-3.2$ mkdir /home/12amca29/Exam3/Exam31
7. Move to Exam2 Directory
-bash-3.2$ cd /home/12amca29/Exam2
8. Using VI, create a file named test1 that contains atleast ten lines.
-bash-3.2$ vi test1
-bash-3.2$ cat test1
Linux
Python
Networks
OR
Multimedia
OOD
Java
Datacommunication
Software engineering
System software
9. Count the number of words , lines and characters in this file
-bash-3.2$ echo "no.of words:"`wc -w test1`
no.of words:12 test1
-bash-3.2$ echo "no.of lines:"`wc -l test1`
no.of lines:10 test1
-bash-3.2$ echo "no.of characters:"`wc -c test1`
no.of characters:100 test1
10. Make a copy of test1 and call it test1.bk.store it under the same directory where
test1 is stored.
-bash-3.2$ cp test1 test1.bk
11. Check the permission of test1
-bash-3.2$ ls -l test1

-rw-rw-r-- 1 12amca29 12amca29 53 Oct 6 14:18 test1


12. Store UNIX vs. LINUX in a variable called OS.
-bash-3.2$ OS="UNIX vs. LINUX"
13. Print the contents of OS in such a way that UNIX vs should print in oneline
LINUX should print in another line
bash-3.2$ echo $OS | tr "." "\n"
LINUX vs
UNIX
14. Use the appropriate command or System variable to determine your login shell
-bash-3.2$ echo $SHELL
/bin/bash
15. Use the /etc /passwd file to verify the result of step 14.
-bash-3.2$ cat /etc/passwd
12amca01:x:826:826:albin,mca,0235045,9785232:/home/12amca01:/bin/bash
10amca05:x:827:827::/home/10amca05:/bin/bash
12amca02:x:828:828:Jazeer:/home/12amca02:/bin/bash
16. Use the appropriate command to determine your current shell. Is it the same as
your login shell?
17. display the last 4 lines of /etc/passwd using proper commands.
-bash-3.2$ tail -4 /etc/passwd
14lmca30:x:1125:1125::/home/14lmca30:/bin/bash
14lmca31:x:1126:1126::/home/14lmca31:/bin/bash
14lmca32:x:1127:1127::/home/14lmca32:/bin/bash
shankar:x:1128:1128::/home/shankar:/bin/bash
18. Move to your home directory.
-bash-3.2$ pwd
/home/12amca29
-bash-3.2$ cd ..
-bash-3.2$
19. Recursively lists all of the directories you created and draw the directory
structure on paper.
-bash-3.2$ ls -R
vin.sh
pgm6.sh nv
mbox
examsecond Desktop
vinaya
pgm5.sh n.sh
m
exam3
dead.letter
test1.bk pgm4.sh nn1
linux exam2.sh0 dbms
test1
pgm3.sh new.sh
links exam2
c.sh
sum1.sh pgm2.sh New Folder .exe link1 exam1.sh cpp
SemIV.pdf pgm1.sh newdir
java exam1
c
regsvr.exe pgm10.sh new1
hw41
even.sh b
Python
pal.sh neem.sh
grepfile echo
autorun.inf
prime.sh ood mine n1.sh
file2 ds
ass.sh
prime1.sh odd.sh n
file1 direct1 asmnt1
pgm7.sh odd1.sh md
file dir1
0

Question#2
Write a Shell Program to perform the
following operations 1) Addition
2)Subtraction 3) Multiplication 4)Division
(Hint: Value should read from the
Keyboard, floating point values should given as input)
echo "Enter num1"
read num1
echo "Enter num2"
read num2
echo "1.Add"
echo "2.Subtract"
echo "3.Divide"
echo "4.Multiply"
while true
do
echo "Enter your choise"
read ch
case $ch in
1)
#c=` expr $num1 + $num2 `
echo "Sum"
echo "$num1 + $num2" | bc ;;
2)
echo "Difference"
echo "$num1 - $num2 " | bc ;;
3)
echo "quotient"
echo "$num1 / $num2" | bc ;;
4)
echo "Product"
echo "$num1 * $num2" |bc ;;
*)
echo "Wrong choice"
break;;
esac
done
Menu
1.Add
2.Subtract
3.Multiplication
4.Division
Enter your choise :
1
Enter the numbers :

12
10
The sum is :
22
Enter your choice :
2
The difference is :
2
Enter your choise :
3
The product is :
120
Enter your choise :
4
The quotient is :
2
Enter your choise :
5
wrong choice
Linux Shell Programming LAB
Question #1
1. Check which group or groups you belong to.
-bash-3.2$ groups 12amca29
12amca29: 12amca29
2. Use the unmask command to set the default permission to be 700 for directories.
What is the default permission for files after this command?
-bash-3.2$ umask 0077
you have read/write access for files, and read/write/search for directories you own.
All others have no access permissions to your files or directories.
3. Create a directory named ExamSecond under your home directory.
-bash-3.2$ mkdir examsecond
4. Check the default permission of this directory. Is it 700?
-bash-3.2$ ls l
drwxrwxr-x 3 12amca29 12amca29 4096 Oct 10 17:16 examsecond
5. Create a directory under ExamSecond directory (without moving from your
home directory) and name it ExamSecond1 directory.
bash-3.2$ mkdir /home/12amca29/examsecond/examsecond1
6. Check the permission of this directory. Is it 700?
bash-3.2$ cd examsecond
bash-3.2$ ls -l
total 4
drwx------ 2 11bmca17 11bmca17 4096 Nov 15 12:53 examsecond1
7. Move to the ExamSecond1 directory.
bash-3.2$ cd examsecond1
8. Create a file named hw41 under this directory and add some information to the
file.
bash-3.2$ vi hw41

9. Save this file.


:wq
10. Check the permission of this file. Is it 700 or 600?
-bash-3.2$ ls -l hw41
-rw-rw-r-- 1 12amca29 12amca29 13 Oct 14 14:45 hw41
11. Do users in your group have any access to this file? Do other users (outside of your
group) have any access to this file?
No ,nither users in group nor other users outside the group have any access to this
file
12.Use the who command and redirect the result to a file called file1. Use the more
command to see the contents of file 1.
-bash-3.2$ who>file|more file
::::::::::::::
file
::::::::::::::
root :0
2014-10-14 11:52
--More
root :0
2014-10-14 11:52
12amca24 pts/1
2014-10-14 14:27 (192.168.101.23)
12bmca11 pts/2
2014-10-14 13:26 (192.168.101.144)
12amca10 pts/3
2014-10-14 14:28 (192.168.101.10)
12amca19 pts/4
2014-10-14 14:35 (192.168.101.18)
12amca26 pts/5
2014-10-14 14:30 (192.168.101.24)
12amca18 pts/6
2014-10-14 14:28 (192.168.101.17)
12amca30 pts/7
2014-10-14 14:28 (192.168.101.28)
12amca17 pts/8
2014-10-14 14:28 (192.168.101.16)
12amca23 pts/9
2014-10-14 14:28 (192.168.101.22)
12amca20 pts/10
2014-10-14 14:28 (192.168.101.19)
12amca13 pts/11
2014-10-14 14:28 (192.168.101.20)
12amca27 pts/12
2014-10-14 14:28 (192.168.101.26)
12amca22 pts/13
2014-10-14 14:29 (192.168.101.21)
12amca16 pts/14
2014-10-14 14:29 (192.168.101.15)
12amca31 pts/15
2014-10-14 14:29 (192.168.101.12)
12amca05 pts/16
2014-10-14 14:29 (192.168.101.4)
12amca14 pts/17
2014-10-14 14:29 (192.168.101.13)
12amca12 pts/18
2014-10-14 14:29 (192.168.101.11)
12bmca15 pts/19
2014-10-14 13:31 (192.168.101.56)
12amca25 pts/20
2014-10-14 14:29 (192.168.101.25)
12amca15 pts/21
2014-10-14 14:30 (192.168.101.14)
12amca08 pts/23
2014-10-14 14:40 (192.168.101.5)
12amca01 pts/24
2014-10-14 14:36 (192.168.101.1)
12amca29 pts/25
2014-10-14 14:39 (192.168.101.27)
10amca21 pts/26
2014-10-14 14:30 (192.168.101.30)
13.Use the date and who commands in sequence (in one line) such that the output of
date will display on the screen and the output of who will be redirected to a file
called file2. Use the more command to check the contents of file2. It should be same
as file1 unless someone logged in or logged off between the who commands.

-bash-3.2$ who>file2|date
Tue Oct 14 14:52:01 IST 2014
-bash-3.2$ more file2
root :0
2014-10-14 11:52
12amca24 pts/1
2014-10-14 14:27 (192.168.101.23)
12bmca11 pts/2
2014-10-14 13:26 (192.168.101.144)
12amca10 pts/3
2014-10-14 14:28 (192.168.101.10)
12amca19 pts/4
2014-10-14 14:35 (192.168.101.18)
12amca26 pts/5
2014-10-14 14:30 (192.168.101.24)
12amca18 pts/6
2014-10-14 14:28 (192.168.101.17)
12amca30 pts/7
2014-10-14 14:28 (192.168.101.28)
12amca17 pts/8
2014-10-14 14:49 (192.168.101.16)
12amca23 pts/9
2014-10-14 14:28 (192.168.101.22)
12amca20 pts/10
2014-10-14 14:28 (192.168.101.19)
12amca13 pts/11
2014-10-14 14:28 (192.168.101.20)
12amca27 pts/12
2014-10-14 14:28 (192.168.101.26)
12amca22 pts/13
2014-10-14 14:29 (192.168.101.21)
12amca16 pts/14
2014-10-14 14:29 (192.168.101.15)
12amca31 pts/15
2014-10-14 14:29 (192.168.101.12)
12amca05 pts/16
2014-10-14 14:29 (192.168.101.4)
12amca14 pts/17
2014-10-14 14:29 (192.168.101.13)
12amca12 pts/18
2014-10-14 14:29 (192.168.101.11)
12bmca15 pts/19
2014-10-14 13:31 (192.168.101.56)
12amca25 pts/20
2014-10-14 14:29 (192.168.101.25)
12amca15 pts/21
2014-10-14 14:30 (192.168.101.14)
12amca09 pts/22
2014-10-14 14:49 (192.168.101.2)
14.Without using an editor, create a one-line file, called file1, using the echo
command (use output redirection). This is one of the way we can create a short file
quickly.
-bash-3.2$ echo "linux assignment" >file
15.Check the contents of file1 using the more command
more file
linux assignment
16.Move to your home directory
-bash-3.2$ cd /home/12amca29
17.Recursively lists all of the directories you created and draw the directory
structure on paper.
-bash-3.2$ ls -R
./examsecond:
examsecond1
./examsecond/examsecond1:
file1s file2 hw41

Question#2
The length & breadth of a rectangle and radius of a circle are input through the
keyboard. Write a program to calculate area & perimeter of the rectangle, and the
area &circumference of the circle
echo "Enter the length of rectangle"
read l
echo "Enter the breadth of rectangle"
read b
echo "Enter the radius of circle"
read r
echo "Area of rectangle is "
echo " $l * $b"|bc
echo "Perimeter of rectangle is "
echo "2 * ($l + $b)"|bc
echo "Area of circle is"
echo "3.14 * $r * $r" |bc
echo ""
echo "3.14 * $r * 2"|bc
Enter the length of rectangle
2
Enter the breadth of rectangle
3
Enter radius of rectangle :
1
Area of rectangle is
6
Perimeter of rectangle is
10
Area of circle is
3.14
Circumference of circle is
6.28

Session 2
1.Recurively lists the directories under your home directory (the ones created in
session 1)
-bash-3.2$ ls -R
.:
./scripts/check/new:
casecondition.sh ifarthimetic.sh iffile.sh simpleifand.sh simpleiftest
exit.sh
ifelif.sh
ifstring.sh simpleif.sh
./scripts/check/rest:
casecondition.sh ifarthimetic.sh iffile.sh simpleifand.sh simpleiftest
exit.sh
ifelif.sh
ifstring.sh simpleif.sh
./scripts/loop:
b
continue.sh for2.sh forex1.sh pos.sh
whilefalse.sh
break.sh for1.sh
for3.sh newex.sh untiltrue.sh
./scripts/myfile:
./session_i:
./UNIX:
hw4SL hw.bk
2. Move to the UNIX directory.
-bash-3.2$ mkdir UNIX
-bash-3.2$ cd UNIX
3. Check your current directory
-bash-3.2$ pwd
/home/12amca29/UNIX
4. Using VI, create a file named hw4 that contains short answers to at least five
review questions in this chapter.
1.how to create a directory?
directory is created by using mkdir command
2.how we can move to a directory?
we can move to a directory by using cd command
3.specify the command which is used to view the current working directory?
command is pwd
4.which command is used for coping one file to another
cp command is used for coping one file to another
5.defult permission value for ordinary file?
value is 666
5. Save the file (it should be saved under the UNIX directory).

:wq
6. Move to your home directory
-bash-3.2$ cd ..
-bash-3.2$ pwd
/home/12amca29/UNIX
7. Print the content of hw4 from your home directory.
-bash-3.2$ cat /home/12amca29/UNIX/hw4
1.how to create a directory?
directory is created by using mkdir command
2.how we can move to a directory?
we can move to a directory by using cd command
3.specify the command which is used to view the current working directory?
command is pwd
4.which command is used for coping one file to another
cp command is used for coping one file to another
5.defult permission value for ordinary file?
value is 666
8. Make a copy of hw4 and call it hw4.bk.store it under the same directory where
hw4 is stored.
-bash-3.2$ cd UNIX
-bash-3.2$ cp hw4 hw4.bk
-bash-3.2$ cat hw4.bk
1.how to create a directory?
directory is created by using mkdir command
2.how we can move to a directory?
we can move to a directory by using cd command
3.specify the command which is used to view the current working directory?
command is pwd
4.which command is used for coping one file to another
cp command is used for coping one file to another
5.defult permission value for ordinary file?
value is 666
9. from your home directory, check to see if both files (hw4 and hw4.bk) exit.
-bash-3.2$ cd ..
-bash-3.2$ pwd
/home/12amca29
-bash-3.2$ ls /home/12amca29/UNIX
hw4 hw4.bk
10. Move to the UNIX directory
-bash-3.2$ cd UNIX
11. Check your current working directory.
-bash-3.2$ pwd
/home/120mca29/UNIX
12. Make a hard link to the hw4 file. The link should be under the UNIX
subdirectory and be called hw4HL.
-bash-3.2$ ln hw4 hw4HL
13. Make a soft link to hw4 called hw4SL and store it under the UNIX directory
-bash-3.2$ ln -s hw4 hw4SL

14. Check the inode of hw4, hw4.bk, hw4SL.Are all the same? Are all different?
Explain how you determined the answer.
-bash-3.2$ ls -li
total 12
10814523 -rw-rw-r-- 2 12amca29 12amca29 409 Oct 12 15:33 hw4
7668672 -rw-rw-r-- 1 12amca29 12amca29 409 Oct 12 12:41 hw4.bk
10814523 -rw-rw-r-- 2 12amca29 12amca29 409 Oct 12 15:33 hw4HL
7668669 lrwxrwxrwx 1 12amca29 12amca29 3 Oct 12 12:53 hw4SL -> hw4
Here inoder number is same for file hw4 and its hard link.
15. Use the ls command to find the file types of hw4, hw4.bk, hw4HL, and
hw4SL.Explain your observation.
-bash-3.2$ ls
hw4 hw4.bk hw4HL hw4SL

Session 3
1. Create a backup directory in your home directory called backups.
-bash-3.2$ tar -cf backups.tar *
2. Use the find command to find the pathnames of all the files (hw4, hw4.bk, hw4HL,
and hw4SL) that you created in session 2.All of them should be found using only one
find command. The command must also copy all of them to the backups directory.
-bash-3.2$ find /home/12amca29/UNIX
/home/12amca29/UNIX
/home/12amca29/UNIX/hw4
/home/12amca29/UNIX/hw4SL
/home/12amca29/UNIX/hw4.bk
/home/12amca29/UNIX/hw4HL
3. Check the number of links and inode number of hw4, hw4.bk, hw3HL, and
hw4SL.Make note of the results.
-bash-3.2$ ls -li
total 12
10814523 -rw-rw-r-- 2 12amca29 12amca29 409 Oct 12 15:33 hw4
7668672 -rw-rw-r-- 1 12amca29 12amca29 409 Oct 15 12:41 hw4.bk
10814523 -rw-rw-r-- 2 12amca29 12amca29 409 Oct 12 15:33 hw4HL
7668669 lrwxrwxrwx 1 12amca29 12amca29 3 Oct 15 12:53 hw4SL -> hw4
4. Delete the original hw4 file without moving from your home directory.
-bash-3.2$ rm -r /home/12amca29/UNIX/hw4
5. Check the existence of hw4, hw4.bk, hw3HL, and hw4SL.
-bash-3.2$ cd UNIX
-bash-3.2$ ls
hw4.bk hw4HL hw4SL
6. Check the contents of hw4, hw4.bk, hw3HL, and hw4SL.
-bash-3.2$ cat hw4.bk
1.how to create a directory?
directory is created by using mkdir command
2.how we can move to a directory?
we can move to a directory by using cd command
3.specify the command which is used to view the current working directory?
command is pwd
4.which command is used for coping one file to another
cp command is used for coping one file to another
5.defult permission value for ordinary file?
value is 666

-bash-3.2$ cat hw4HL


1.how to create a directory?
directory is created by using mkdir command
2.how we can move to a directory?
we can move to a directory by using cd command
3.specify the command which is used to view the current working directory?
command is pwd
4.which command is used for coping one file to another
cp command is used for coping one file to another
5.defult permission value for ordinary file?
value is 666
-bash-3.2$ cat hw4SL
cat: hw4SL: No such file or directory
7. Restore the file hw4 by making a copy of hw4.bk
-bash-3.2$ cp hw4.bk hw4
8. You may have noticed that your soft link (hw4SL) contains garbage. Delete this
file.
-bash-3.2$ rm -r hw4SL
9. Make a new soft link to hw4 and store it as hw4SL under the same directory as it
was.
-bash-3.2$ ln -s hw4 hw4SL
10. List recursively all of your files and directories to confirm all operations.
-bash-3.2$ sls -R
./UNIX:
hw4 hw4.bk hw4HL hw4SL

Session 4
1.Wildcards to display all of the files you have created under the HWs directory
without moving from your home directory.
-bash-3.2$ ls UNIX/*
UNIX/hw4 UNIX/hw4.bk UNIX/hw4HL UNIX/hw4SL
2.Rename hw4.bk to hw4.bak.
-bash-3.2$ mv UNIX/hw4.bk UNIX/hw4.bak
-bash-3.2$ ls UNIX
hw4 hw4.bak hw4HL hw4SL
3.Create a short friendly letter, called friend .1, using vi and store it under the
friendly directory.
-bash-3.2$ vi friend.1
-bash-3.2$ cat friend.1
dear friend
how are you?.I hope you are doing well.
What about your family?
convey my regards to your family.I hope god may bless you with all the happiness
in the world........
with lots of love & prayers
your best friend.
4.Create a short formal letter, called formal .1, using vi and store it under the formal
directory. Give a title to formal.1 letter.
-bash-3.2$ vi formal.1
-bash-3.2$ cat formal.1
FORMAL LETTER TO TEACHER
From,
Vinaya Augustine
4A mca
To,
The class teacher
4A mca
Respected sir,

As i was suffering from fever i humbly request you to grand me half day
leave.
yuor's faithfully
Vinaya Augustine
5.Copy the file formal. 1 and call the new copy formal.2.
-bash-3.2$ cp formal.1 formal.2
-bash-3.2$ cat formal.2
FORMAL LETTER TO TEACHER
From,
Vinaya Augustine
4A mca
To,
The class teacher
4A mca
Respected sir,
As i was suffering from fever i humbly request you to grand me half day
leave.
Yours faithfully
Vinaya Augustine
6.Change only the title of formal.2 (using vi) and store it.
-bash-3.2$ vi formal.2
-bash-3.2$ cat formal.2
FORMAL LETTER TO CLASS TEACHER
From,
Vinaya Augustine
4A mca
To,
The class teacher
4A mca
Respected sir,
As i was suffering from fever i humbly request you to grand me half day
leave.
Yours faithfully
Vinaya Augustine
7.Using wildcards print the contents of formal.1 and formal.2.
-bash-3.2$ cat formal.[1,2]
FORMAL LETTER TO TEACHER
From,
Vinaya Augustine
4A mca

To,
The class teacher
4A mca
Respected sir,
As i was suffering from fever i humbly request you to grand me half day
leave.
Yours faithfully
Vinaya Augustine
FORMAL LETTER TO TEACHER
From,
Vinaya Augustine
4A mca
To,
The class teacher
4A mca
Respected sir,
As i was suffering from fever i humbly request you to grand me half day
leave.
Yours faithfully
Vinaya Augustine
8.Make a directory called bus Letters under your home directory.
-bash-3.2$ mkdir bus_LETTERS
-bash-3.2$ ls
Exam2
friendly Exam3 backups.tar ExamScond1 ExamSecond
bus_LETTERS ExamSecond1
UNIX Exam1 formal
NGG
9.Move the formal directory (with all of its contents) under the bus Letters directory.
-bash-3.2$mv formal bus_LETTERS
-bash-3.2$ls bus_LETTERS
formal
-bash-3.2$ cat bus_LETTERS/formal/formal.1
FORMAL LETTER TO TEACHER
From,
Vinaya Augustine
4A mca
To,
The class teacher
4A mca
Respected sir,
As i was suffering from fever i humbly request you to grand me half day
leave.
Yours faithfully
Vinaya Augustine

10.Make a recursive list of your directory structure.


./Exam1:
Exam11 Exam12
./Exam1/Exam11:
./Exam1/Exam12:
./Exam2:
Exam21 Exam22 Exam23 test1 test1.bk
./Exam2/Exam21:
./Exam2/Exam22:
./Exam2/Exam23:
./Exam3:
Exam31
./Exam3/Exam31:
./ExamScond1:
./ExamSecond:
ExamSecond1
./ExamSecond/ExamSecond1:
file1 file2 hw41
./ExamSecond1:
./f:
./friendly:
friend.1
./bus_LETTERS:
formal
./bus_LETTERS/formal:
formal.1
formal.2
./UNIX:
hw4 hw4.bak hw4HL hw4SL
11. Draw the new directory structure on paper.
|-- bus_LETTERS
| `-- formal
|
|-- formal.1
|
`-- formal.2
|-- f
|-- friendly
| `-- friend.1

Session 5
1.Check which group or groups you belong to.
-bash-3.2$ groups
12amca29
-bash-3.2$ id
uid=855(12amca29) gid=855(12amca29) groups=855(12amca29)
2.Use the unmask command to set the default permission to be 700 for directories.
What is the default permission for files after this command?
-bash-3.2$ umask
0002
-bash-3.2$ umask 700
-bash-3.2$ unmask
-bash: unmask: command not found
-bash-3.2$ umask
0700
-bash-3.2$ umask 077
-bash-3.2$ umask
0077
3.Create a directory named CHAPTER_4 under your home directory.
-bash-3.2$ mkdir CHAPTER_4
4.Check the default permission of this directory. Is it 700?
-bash-3.2$ stat /home/12amca29/CHAPTER_4
File: `/home/12amca29/CHAPTER_4'
Size: 4096
Blocks: 8
IO Block: 4096 directory
Device: 805h/2053d
Inode: 22053554 Links: 2
Access: (0775/drwxrwxr-x) Uid: ( 855/12amca29) Gid: ( 855/12amca29)
Access: 2014-10-14 16:14:07.000000000 +0530
Modify: 2014-10-14 16:12:29.000000000 +0530
Change: 2014-10-14 16:12:29.000000000 +0530

5.Create a directory under CHAPTER_4 directory (without moving from your home
directory) and name it session_i directory.
-bash-3.2$ mkdir /home/12amca29/CHAPTER_4/session_i
6.Check the permission of this directory. Is it 700?
-bash-3.2$ stat /home/12amca29/CHAPTER_4/session_i
File: `/home/12amca29/CHAPTER_4/session_i'
Size: 4096
Blocks: 8
IO Block: 4096 directory
Device: 805h/2053d
Inode: 22053555 Links: 2
Access: (0700/drwx------) Uid: ( 855/12amca29) Gid: ( 855/12amca29)
Access: 2014-10-14 16:26:18.000000000 +0530
Modify: 2014-10-14 16:26:18.000000000 +0530
Change: 2014-10-14 16:26:18.000000000 +0530
7.Move to the session_i directory.
-bash-3.2$ cd /home/12amca29/CHAPTER_4/session_i
-bash-3.2$ pwd
/home/12amca29/CHAPTER_4/session_i
8.Create a file named hw41 under this directory and add some information to the
file.
-bash-3.2$ vi hw41
9.Save this file.
:wq
10.Check the permission of this file. Is it 700 or 600? Why? Explain the difference
between the permissions for files and directories.
-bash-3.2$ stat hw41
File: `hw41'
Size: 11
Blocks: 8
IO Block: 4096 regular file
Device: 805h/2053d
Inode: 13205512 Links: 1
Access: (0600/-rw-------) Uid: ( 855/12amca29) Gid: ( 855/12amca29)
Access: 2014-10-14 16:28:36.000000000 +0530
Modify: 2014-10-14 16:28:36.000000000 +0530
Change: 2014-10-14 16:28:36.000000000 +0530
11.Do users in your group have any access to this file? Do other users (outside of
your group) have any access to this file?
-bash-3.2$ ls -l /home/12amca29/CHAPTER_4
total 4
drwx------ 2 12amca29 12amca29 4096 Oct 14 16:28 session_i
12.Change the permissions to allow users in your group only to copy this file to their
own directories. Is there a need to change the permission of any directories? Is yes,
make the necessary changes.
-bash-3.2$ chmod g+rw hw41
-bash-3.2$ ls -l
total 4
-rw-rw---- 1 12amca27 12amca27 11 Oct 14 15:20 hw41

13. Ask a user in your group to copy this file into his or her home directory. Was the
copy successful? If not, find the reason and take the appropriate actions to correct it.
Then have your user-group friend try again.
Yes the copy is successful

Session 6
1.Check which group or groups you belong to .
-bash-3.2$ groups
12amca29
2.Check your default mask.
-bash-3.2$ umask
0002
3.Create a directory called garbage under your home directory.
-bash-3.2$ mkdir garbage
4. Check the permission of this directory.Make a note of it.
-bash-3.2$ stat garbage
File: `garbage'
Size: 4096
Blocks: 8
IO Block: 4096 directory
Device: 805h/2053d
Inode: 22053556 Links: 2
Access: (0700/drwx------) Uid: ( 855/12amca29) Gid: ( 855/12amca29)
Access: 2014-10-14 16:32:36.000000000 +0530
Modify: 2014-10-14 16:32:36.000000000 +0530
Change: 2014-10-14 16:32:36.000000000 +0530
5.Change your default mask so that the default permission is 664.What is the default
permission for directories after you make this change?
-bash-3.2$ umask 664
-bash-3.2$ umask
0664
6.Check the permission for the garbage directory.Has it been changed after setting
the default mask?Why or why not?
-bash-3.2$ stat garbage
File: `garbage'

Size: 4096
Blocks: 8
IO Block: 4096 directory
Device: 805h/2053d
Inode: 22053556 Links: 2
Access: (0700/drwx------) Uid: ( 855/12amca29) Gid: ( 855/12amca29)
Access: 2014-10-14 16:32:36.000000000 +0530
Modify: 2014-10-14 16:32:36.000000000 +0530
Change: 2014-10-14 16:32:36.000000000 +0530
7. Delete this directory.
-bash-3.2$ rmdir garbage
8.Create a directory called session_II under the chapter_4 directory.
-bash-3.2$ mkdir session_II
9. Check the permission of this directory and make a note of it.
-bash-3.2$ stat session_II
File: `session_II'
Size: 4096
Blocks: 8
IO Block: 4096 directory
Device: 805h/2053d
Inode: 22053556 Links: 2
Access: (0113/d--x--x-wx) Uid: ( 855/12amca29) Gid: ( 855/12amca29)
Access: 2014-10-14 16:35:16.000000000 +0530
Modify: 2014-10-14 16:35:16.000000000 +0530
Change: 2014-10-14 16:35:16.000000000 +0530
11. Remove the x permission for the user from this directory.
-bash-3.2$ chmod u-x session_II
12. Move to session_II directory.You should have a problem.Do you know what the
problem is?Fix the problem.
-bash-3.2$ cd session_II
-bash: cd: session_II: Permission denied
13. Create a file named hw_4_2 under this directory and type answers to question 11.
-bash-3.2$ vi hw_4_2
14. Save this file.
:wq
15. Check the permissions of this file.Can users in your group copy this file?Can they
change this file?Can users outside your group copy this file?Can they change this
file?Is this file executable?
-bash-3.2$ ls -l hw_4_2
--------w- 1 12amca29 12amca29 22 Oct 14 16:38 hw_4_2
15. Change the permissions of this file so that every user can read ,modify,but not
execute this file.
-bash-3.2$ chmod u+r hw_4_2
-bash-3.2$ chmod u+w hw_4_2
-bash-3.2$ ls -l hw_4_2
-rw-----w- 1 12amca29 12amca29 22 Oct 14 16:38 hw_4_2
16. Print this file.
-bash-3.2$ cat hw_4_2
chmod u-x session_II

Session 7
1. Use the appropriate command to determine your login shell.
-bash-3.2$ echo $0
-bash
2. Use the /etc /passwd file to verify the result of step 2.
-bash-3.2$ grep "12amca29" </etc/passwd
12amca29:x:855:855:vinaya:/home/12amca29:/bin/bash
3. Use the appropriate command to determine your current shell. Is it the same
as your login shell?
-bash-3.2$ echo $SHELL
/bin/bash
-bash-3.2$ echo $0
-bash
4. Create a subshell shell that is not the same shell as your login shell. ( if your
login shell is korn, create a bash or C shell.
bash-3.2$ echo $PS1
\s-\v\$
-bash-3.2$ echo PS1=vinaya
PS1=vinaya
5. Check the current shell again. Does it match with your login shell?
-bash-3.2$ echo $0
-bash
-bash-3.2$ echo $SHELL
/bin/bash
It dosent match the login shell

6. Create another shell which is the same type as your login shell.
-bash-3.2$ bash
7. Check the current shell again. Does it match with previous one?
-bash-3.2$ echo $0
Bash
No, it doesnt match with the previous one
8. Exit from the subshell shell and move to your login shell.
-bash-3.2$ exit
exit
-bash-3.2$ exit
exit
-bash-3.2$
9. Check the current shall again. Is it the same as the login shell?
-bash-3.2$
echo $0
-bash
-bash-3.2$
echo $SHELL
/bin/bash
Yes,it is.

Session 8
1.Use the who command and redirect the result to a file called file1. Use the more
command to use see the contents of file 1.
-bash-3.2$ who > file1
-bash-3.2$ more file1
root :0
2014-10-14 11:52
12amca18 pts/1
2014-10-14 16:35 (192.168.101.17)
12amca16 pts/3
2014-10-14 16:26 (192.168.101.15)
12amca25 pts/4
2014-10-14 16:26 (192.168.101.25)
12amca10 pts/5
2014-10-14 16:37 (192.168.101.10)
12amca24 pts/6
2014-10-14 16:08 (192.168.101.23)
11amca23 pts/7
2014-10-14 16:27 (192.168.101.29)
12amca29 pts/8
2014-10-14 16:10 (192.168.101.27)
12bmca20 pts/9
2014-10-14 16:35 (192.168.101.81)
12amca05 pts/10
2014-10-14 16:28 (192.168.101.4)
12amca23 pts/11
2014-10-14 16:28 (192.168.101.22)
12amca08 pts/12
2014-10-14 16:28 (192.168.101.7)
12bmca13 pts/13
2014-10-14 16:35 (192.168.101.89)
12amca26 pts/14
2014-10-14 16:29 (192.168.101.24)
12amca30 pts/15
2014-10-14 16:29 (192.168.101.28)
12amca14 pts/16
2014-10-14 16:29 (192.168.101.13)
12amca07 pts/17
2014-10-14 16:30 (192.168.101.6)
12amca06 pts/18
2014-10-14 16:29 (192.168.101.5)
10amca21 pts/19
2014-10-14 16:29 (192.168.101.30)
12amca22 pts/20
2014-10-14 16:30 (192.168.101.21)
12amca02 pts/21
2014-10-14 16:30 (192.168.101.3)

12amca11 pts/22
2014-10-14 16:31 (192.168.101.9)
12amca32 pts/23
2014-10-14 16:31 (192.168.101.2)
12amca09 pts/24
2014-10-14 16:31 (192.168.101.8)
2.Use the date and who commands in sequence (in one line) such that the output of
date will display on the screen and the output of who will be redirected to a file
called file2. Use the more command to check the contents of file2. It should be same
as file1 unless someone logged in or logged off between the who commands.
-bash-3.2$ date> /dev/pts/8|who>file2
Tue Oct 14 16:49:38 IST 2014
-bash-3.2$ more file2
root :0
2014-10-14 11:52
12amca18 pts/1
2014-10-14 16:35 (192.168.101.17)
12bmca28 pts/2
2014-10-14 16:47 (192.168.101.87)
12amca16 pts/3
2014-10-14 16:26 (192.168.101.15)
12amca25 pts/4
2014-10-14 16:26 (192.168.101.25)
12amca10 pts/5
2014-10-14 16:37 (192.168.101.10)
12amca24 pts/6
2014-10-14 16:08 (192.168.101.23)
11amca23 pts/7
2014-10-14 16:27 (192.168.101.29)
12amca29 pts/8
2014-10-14 16:10 (192.168.101.27)
12bmca20 pts/9
2014-10-14 16:35 (192.168.101.81)
12amca05 pts/10
2014-10-14 16:28 (192.168.101.4)
12amca23 pts/11
2014-10-14 16:28 (192.168.101.22)
12amca08 pts/12
2014-10-14 16:28 (192.168.101.7)
12bmca13 pts/13
2014-10-14 16:35 (192.168.101.89)
12amca26 pts/14
2014-10-14 16:29 (192.168.101.24)
12amca30 pts/15
2014-10-14 16:29 (192.168.101.28)
12amca14 pts/16
2014-10-14 16:29 (192.168.101.13)
12amca07 pts/17
2014-10-14 16:30 (192.168.101.6)
12amca06 pts/18
2014-10-14 16:29 (192.168.101.5)
10amca21 pts/19
2014-10-14 16:29 (192.168.101.30)
12amca22 pts/20
2014-10-14 16:30 (192.168.101.21)
12amca02 pts/21
2014-10-14 16:30 (192.168.101.3)
12amca11 pts/22
2014-10-14 16:31 (192.168.101.9)
12amca32 pts/23
2014-10-14 16:31 (192.168.101.2)
3. Set vi to be your command line editor.
-bash-3.2$ set -o vi
4. Use your command line editor to recall the line you typed in step2. Edit the
line so that the output of both commands (date and who) are redirected to a file
called file3. Use the more command to display the result.
-bash-3.2$ set -o vi
[Esc] + v
date >file3 | who >>file3
more file3
~
"/tmp/bash-fc-1413366818" 2L, 37C written
date >file3 | who >>file3
more file3
Wed Oct 15 15:18:18 IST 2014

12amca29 pts/1
2014-10-15 14:37 (192.168.101.186)
12amca31 pts/2
2014-10-15 13:10 (192.168.101.54)
12amca22 pts/3
2014-10-15 13:11 (192.168.101.208)
12amca01 pts/4
2014-10-15 13:11 (192.168.101.36)
12amca11 pts/5
2014-10-15 14:36 (192.168.101.70)
--More--(35%)
5. Use the command line editor to recall the line you typed in step2 Edit the line so
that the output of the first command (date) is redirected to a file called file4, while
the result of the who command displays on the monitor without changing the
relative positions of the date and who commands. Use the more command to
verify the result.
-bash-3.2$ set -o vi
[Esc] + v
date >file4 | who
more file4
~
"/tmp/bash-fc-4232221900" 2L, 29C written
date >file4 | who
12amca29 pts/1
2014-10-15 14:37 (192.168.101.186)
12amca31 pts/2
2014-10-15 15:24 (192.168.101.54)
12amca22 pts/3
2014-10-15 13:11 (192.168.101.208)
12amca01 pts/4
2014-10-15 13:11 (192.168.101.36)
12amca11 pts/5
2014-10-15 14:36 (192.168.101.70)
more file4
Wed Oct 15 15:24:06 IST 2014
6. Make a duplicate of file3 and call it file3.bak
-bash-3.2$ set -o vi
[Esc] + v
cp file3 file3.bak
~
"/tmp/bash-fc-2897968360" 1L, 19C
cp file3 file3.bak
-bash-3.2$ cat file3.bak
Wed Oct 15 15:18:18 IST 2014
12amca29 pts/1
2014-10-15 14:37 (192.168.101.186)
12amca31 pts/2
2014-10-15 13:10 (192.168.101.54)
12amca22 pts/3
2014-10-15 13:11 (192.168.101.208)
12amca01 pts/4
2014-10-15 13:11 (192.168.101.36)
12amca11 pts/5
2014-10-15 14:36 (192.168.101.70)

ession 9
1. Without using an editor, create a one-line file, called file1, using the echo
command (use output redirection). This is one of the way we can create a
short file quickly.
-bash-3.2$ echo "Hello.." >file1
-bash-3.2$ cat file1
Hello..
2. Check the contents of file1 using the more command
-bash-3.2$ more file1
Hello..
3. Now, without using an editor, create a two line file, file2, using the echo
command. Use double quotes for the argument of the echo command. Put the
opening quote in the first line and the closing quotes in the second line, but do
not close it until the end of the second line. In your own words, explain what
you just did and why it works.
-bash-3.2$ echo " This is a program to create a two line file
> using echo
>
> ">file2
-bash-3.2$ cat file2
This is a program to create a two line file

using echo

4. Check the contents of file2 using the more command


-bash-3.2$ more file2
This is a program to create a two line file
using echo
5. Store UNIX vs. others in a variable called facts.
-bash-3.2$ s="UNIX vs.others"
-bash-3.2$ echo $s
UNIX vs.others

6. Now use the following command:


echo This is a fact $facts in our file.
What is printed and why?
-bash-3.2$ echo "This is a fact $facts in our file"
This is a fact UNIX vs others in our file
Here the value of the variable facts will be printed because of the use of the symbol
$
Session 10
1.Now use the following command echo This is a fact \$facts in your life What
would be printed and why?
-bash-3.2$ echo This is a fact \$facts in your life
This is a fact $facts in your life
2.Try to use a command to print the following message (including the quetes)
using the value of variable facts:
This is a fact UNIX vs. Others in your life
-bash-3.2$ echo "\"This is a fact \"UNIX vs.Others\" in your life\""
"This is a fact "UNIX vs.Others" in your life"
3. Store the word PARENT in a variable called first;
-bash-3.2$ first="PARENT"
4. Print the value of the variable first (using echo command).
-bash-3.2$ echo $first
PARENT
5.Create a subshell shell using the same type of shell as your login shell (Korn
or Bash or C).
-bash-3.2$ echo $SHLVL
1
-bash-3.2$ bash
6. Print the value of variable first in the subshell. What was printed? If
PARENT
was not Printed explain why .

-bash-3.2$ $bash
-bash-3.2$ $bash echo $first
7.PARENTStore the word SUBSHELL in a variable called second
bash-3.2$ second="SUBSHELL"
8.Print the value of the variable second.
bash-3.2$ echo $second
SUBSHELL
9.Exit from the subshell shell and move to your login shell.
bash-3.2$ exit
exit
10.Print the value of first . What was printed? How do you explain the result.
-bash-3.2$ echo $first
PARENT
11.Print the value of second. What was printed? How do you explain this result?
-bash-3.2$ echo $second
No print value

Session 11
1. Use the cat command to create file containing the following data .call it
Ch6S1F1.
1425
JUAN
14.25
4321
GEORGE
21.11
6781
ANNA
16.77
1451
BEN
21.77
2277
TUAN
18.77
-bash-3.2$ cat > Ch6S1FI
1425
JUAN
14.25
4321
GEORGE 21.11
6781
ANNA
16.77
1451
BEN
21.77
2277
TUAN
18.77
2. Use the cat command to display the file and check for accuracy.
-bash-3.2$ cat Ch6S1F1
1425 JUAN 14.25
4321 GEORGE 21.11
6781 ANNA 16.77
1451 BEN 21.77

2277 TUAN

18.77

3. Use the vi command to correct any errors in the file.


-bash-3.2$ vi Ch6S1F1
1425 JUAN 14.25
4321 GEORGE 21.11
6781 ANNA 16.77
1451 BEN 21.77
2277 TUAN 18.77
~
:wq
4. Use sort command to sort the file Ch6S1F1 according to first field . Call the
sorted file Ch6S1F1(same name).
-bash-3.2$ sort Ch6S1F1
1425 JUAN 14.25
1451 BEN 21.77
2277 TUAN 18.77
4321 GEORGE 21.11
6781 ANNA 16.77
5. Print the file Ch6S1F1.
-bash-3.2$ cat Ch6S1F1
1425 JUAN 14.25
4321 GEORGE 21.11
6781 ANNA 16.77
1451 BEN 21.77
2277 TUAN 18.77
6. Use the cut and paste commands to swap fields 2 and 3 of Ch6S1F1.call it as
Ch6S1F1(same name).
-bash-3.2$ tr -s ' ' < Ch6S1F1| cut -d ' ' -f 1,3 > f1
-bash-3.2$ tr -s ' ' < Ch6S1F1| cut -d ' ' -f 2 > f2
-bash-3.2$ paste f1 f2 > Ch6S1F1
7. Print the new file Ch6S1F1.
-bash-3.2$ cat Ch6S1F1
1425 14.25
JUAN
4321 21.11 GEORGE
6781 16.77 ANNA
1451 21.77
BEN
2277 18.77 TUAN

Session 12
1.Use tail command to create and save the following file.Call it Ch6S2F1.
PASSES ALL DATA FROM INPUT TO OUTPUT
PASSES ONLY SPECIFIED COLUMNS
PASSES NUMBER OF SPECIFIED LINES AT BEGINNING
COMBINES COLUMNS
ARRANGES DATA IN SEQUENCE
PASSES NUMBER OF SPECIFIED LINES AT THE END OF DATA
TRANSLATES ONE OR MORE CHARACTERS
DELETES DUPLICATE LINES
COUNTS CHARACTERS , WORDS , OR LINES
ABCDEFGHIJKLMNOPQRSTUVWXYZ
-bash-3.2$ tail >> Ch6S2F1
PASSES ALL DATA FROM INPUT TO OUTPUT
PASSES ONLY SPECIFIED COLUMNS
PASSES NUMBER OF SPECIFIED LINES AT BEGINNING
COMBINES COLUMNS
ARRANGES DATA IN SEQUENCE
PASSES NUMBER OF SPECIFIED LINES AT THE END OF DATA
TRANSLATES ONE OR MORE CHARACTERS

DELETES DUPLICATE LINES


COUNTS CHARACTERS , WORDS , OR LINES
ABCDEFGHIJKLMNOPQRSTUVWXYZ
2.Use cat command to view its contents.
-bash-3.2$ cat Ch6S2F1
PASSES ALL DATA FROM INPUT TO OUTPUT
PASSES ONLY SPECIFIED COLUMNS
PASSES NUMBER OF SPECIFIED LINES AT BEGINNING
COMBINES COLUMNS
ARRANGES DATA IN SEQUENCE
PASSES NUMBER OF SPECIFIED LINES AT THE END OF DATA
TRANSLATES ONE OR MORE CHARACTERS
DELETES DUPLICATE LINES
COUNTS CHARACTERS , WORDS , OR LINES
ABCDEFGHIJKLMNOPQRSTUVWXYZ
3.use vi to correct any errors.
-bash-3.2$ vi Ch6S2F1
PASSES ALL DATA FROM INPUT TO OUTPUT
PASSES ONLY SPECIFIED COLUMNS
PASSES NUMBER OF SPECIFIED LINES AT BEGINNING
COMBINES COLUMNS
ARRANGES DATA IN SEQUENCE
PASSES NUMBER OF SPECIFIED LINES AT THE END OF DATA
TRANSLATES ONE OR MORE CHARACTERS
DELETES DUPLICATE LINES
COUNTS CHARACTERS , WORDS , OR LINES
ABCDEFGHIJKLMNOPQRSTUVWXYZ
~
~
~
~
4.Encrypt this file using the following steps:
a. Reverse the file line by line(the last line becomes the first ,the line before the
last line becomes the second and so on).
b.Call the file Ch6S2F1Encr.
-bash-3.2$ tac Ch6S2F1
ABCDEFGHIJKLMNOPQRSTUVWXYZ
COUNTS CHARACTERS , WORDS , OR LINES
DELETES DUPLICATE LINES
TRANSLATES ONE OR MORE CHARACTERS
PASSES NUMBER OF SPECIFIED LINES AT THE END OF DATA
ARRANGES DATA IN SEQUENCE
COMBINES COLUMNS
PASSES NUMBER OF SPECIFIED LINES AT BEGINNING
PASSES ONLY SPECIFIED COLUMNS
PASSES ALL DATA FROM INPUT TO OUTPUT

-bash-3.2$ tac Ch6S2F1>Ch6S2F1Encr


-bash-3.2$ gpg -c Ch6S2F1Encr
Enter passphrase:
Repeat passphrase:
5.Use the cat command to view its contents.
-bash-3.2$ cat Ch6S2F1Encr
ABCDEFGHIJKLMNOPQRSTUVWXYZ
COUNTS CHARACTERS , WORDS , OR LINES
DELETES DUPLICATE LINES
TRANSLATES ONE OR MORE CHARACTERS
PASSES NUMBER OF SPECIFIED LINES AT THE END OF DATA
ARRANGES DATA IN SEQUENCE
COMBINES COLUMNS
PASSES NUMBER OF SPECIFIED LINES AT BEGINNING
PASSES ONLY SPECIFIED COLUMNS
PASSES ALL DATA FROM INPUT TO OUTPUT
6.Print the file.
-bash-3.2$ cat Ch6S2F1Encr
ABCDEFGHIJKLMNOPQRSTUVWXYZ
COUNTS CHARACTERS , WORDS , OR LINES
DELETES DUPLICATE LINES
TRANSLATES ONE OR MORE CHARACTERS
PASSES NUMBER OF SPECIFIED LINES AT THE END OF DATA
ARRANGES DATA IN SEQUENCE
COMBINES COLUMNS
PASSES NUMBER OF SPECIFIED LINES AT BEGINNING
PASSES ONLY SPECIFIED COLUMNS
PASSES ALL DATA FROM INPUT TO OUTPUT
7.Decrypt the file(reverse the encryption steps).call it Ch6S2F1(original name).
-bash-3.2$ gpg -d Ch6S2F1Encr.gpg
gpg: CAST5 encrypted data
gpg: encrypted with 1 passphrase
ABCDEFGHIJKLMNOPQRSTUVWXYZ
COUNTS CHARACTERS , WORDS , OR LINES
DELETES DUPLICATE LINES
TRANSLATES ONE OR MORE CHARACTERS
PASSES NUMBER OF SPECIFIED LINES AT THE END OF DATA
ARRANGES DATA IN SEQUENCE
COMBINES COLUMNS
PASSES NUMBER OF SPECIFIED LINES AT BEGINNING
PASSES ONLY SPECIFIED COLUMNS
PASSES ALL DATA FROM INPUT TO OUTPUT
gpg: WARNING: message was not integrity protected

Session 13
1.Use the cat command to check its content.
-bash-3.2$ cat Ch6SIFI
1425
JUAN
14.25
4321
GEORGE
21.11
6781
ANNA
16.77
1451
BEN
21.77
2277
TUAN
18.77
2.Use vi to correct any errors.
-bash-3.2$ vi Ch6SIFI
3.Print the file.
-bash-3.2$ vi Ch6SIFI
4.Use a command to show the number of workers.
-bash-3.2$ echo "No of workers : " `sed -n '$=' Ch6SIFI`
No of workers : 5
5.Use a command to sort the file based on id.
-bash-3.2$ sort -k 1 Ch6SIFI
1425
JUAN
14.25

1451
BEN
21.77
2277
TUAN
18.77
4321
GEORGE
21.11
6781
ANNA
16.77
6.Use one single command to show the worker who is paid the heighest hourly
rate.
-bash-3.2$ sort -k 3 Ch6SIFI | sed -n '4,5p'
4321
GEORGE
21.11
1451
BEN
21.77
7. Use one single command to show the worker who worked more than
anybody else.
The command should show only the id of the worker.
-bash-3.2$ sort -k 3 Ch6SlFl | sed -n '5p' | cut -d ' ' -f1
1451

Vous aimerez peut-être aussi