Está en la página 1de 17

G.

BHARATH KUMAR 411615104004

OUTPUT:
1.Date:
[oslab@localhost ~]$date

Fri jan 9 12:20:33 IST 2015

2.Cal:
[oslab@localhost ~]$ cal

January 2015

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 31

3.Echo:
[oslab@localhost ~]$ echo GOOD MORNING

GOOD MORNING

4.Who:
[oslab@localhost ~]$ who

cse014 pts/1 2015-01-09 10:52 (192.168.1.50)

oslab pts/2 2015-01-09 10:52 (192.168.1.168)

CS6413 OPERATING SYSTEMS LABORATORY


G.BHARATH KUMAR 411615104004

5.Who am i:
[oslab@localhost ~]$ who am i

oslab pts/2 2015-01-09 10:52 (192.168.1.168)

6.TTY:
[oslab@localhost ~]$ tty

/dev/pts/2

7.Man:
[oslab@localhost ~]$ man date

DATE(1) User Commands DATE(1)

NAME

date - print or set the system date and time

SYNOPSIS

date [OPTION]... [+FORMAT]

date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]

DESCRIPTION

Display the current time in the given FORMAT, or set the system date.

-d, --date=STRING

display time described by STRING, not now

-f, --file=DATEFILE

like --date once for each line of DATEFILE

-r, --reference=FILE

display the last modification time of FILE

CS6413 OPERATING SYSTEMS LABORATORY


G.BHARATH KUMAR 411615104004

-R, --rfc-2822

output date and time in RFC 2822 format

--rfc-3339=TIMESPEC

output date and time in RFC 3339 format. TIMESPEC=date,

sec-

onds, or ns for date and time to the indicated precision.

-s, --set=STRING

set time described by STRING

-u, --utc, --universal

print or set Coordinated Universal Time

--help display this help and exit

--version

...skipping...

display time described by STRING, not now

-f, --file=DATEFILE

like --date once for each line of DATEFILE

-r, --reference=FILE

display the last modification time of FILE

-R, --rfc-2822

output date and time in RFC 2822 format

-- output date and time in RFC 3339 format.


TIMESPEC=date,

sec-

onds, or ns for date and time to the indicated precision.

CS6413 OPERATING SYSTEMS LABORATORY


G.BHARATH KUMAR 411615104004

-s, --set=STRING

set time described by STRING

-u, --utc, --universal

print or set Coordinated Universal Time

--help display this help and exit

--version

Directory related commands:


1.Mkdir:
[oslab@localhost ~]$ mkdir int

2.Cd:
[oslab@localhost ~]$cd int

3.Pwd:
[oslab@localhost ~]$pwd

/home/oslab/int

4.Rmdir:
[oslab@localhost ~]$rmdir int

rmdir:int: No such file or directory

5.ls:
[oslab@localhost ~]$ls

CS6413 OPERATING SYSTEMS LABORATORY


G.BHARATH KUMAR 411615104004

Fruits

File manipulation commands


1.cat:
[oslab@localhost ~]$ cat fruits

Mango is a fruit which is delicious and juicy

2.cp:
[oslab@localhost ~]$ cp fruits mango

[oslab@localhost ~]$ cat mango

Mango is a fruit which is delicious and juicy

3.Move:
[oslab@localhost ~]$ mv fruits fruit

[oslab@localhost ~]$ cat fruit

Mango is a fruit which is delicious and juicy

[oslab@localhost ~]$ cat fruits

cat: fruits: No such file or directory

4.Remove:
[oslab@localhost ~]$ rm fruits

[oslab@localhost ~]$ cat fruits

cat: fruits: No such file or directory

CS6413 OPERATING SYSTEMS LABORATORY


G.BHARATH KUMAR 411615104004

5.Word count:
[oslab@localhost ~]$ wc -c mango

46 mango

[oslab@localhost ~]$ wc mango

1 9 46 mango

6.Sort:
[oslab@localhost ~]$ sort demo

File comparison commands:


1.Compare:
[oslab@localhost ~]$cmp demo example

demo example differ : byte 1, line 1

2.Difffer:

[oslab@localhost ~]$diff demo example

>Mango is a fruit which is delicious and juicy

CS6413 OPERATING SYSTEMS LABORATORY


G.BHARATH KUMAR 411615104004

3.Filter:
(a) Head:

[oslab@localhost ~]$head -3 example

Mango is a fruit which is delicious and juicy

(b)Tail:

[oslab@localhost ~]$tail -2 example

FB

4.Numbering:
[oslab@localhost ~]$ nl mango

1 Mango is a fruit which is delicious and juicy

Pattern searching command:


1.GREP:
[oslab@localhost ~]$grep mango example

Mango

PROGRAM:

CS6413 OPERATING SYSTEMS LABORATORY


G.BHARATH KUMAR 411615104004

echo "Enter three numbers"

read a b c

if [ $a -gt $b -a $a -gt $c ]

then

echo "A is big"

elif [ $b -gt $c ]

then

echo "B is big"

else

echo "C is big"

fi

OUTPUT:
[oslab@localhost ~]$ sh large3n.sh

CS6413 OPERATING SYSTEMS LABORATORY


G.BHARATH KUMAR 411615104004

Enter three numbers

873

A is big

PROGRAM:
echo Enter two numbers

CS6413 OPERATING SYSTEMS LABORATORY


G.BHARATH KUMAR 411615104004

read a b

echo 1.ADD 2.SUB 3.MUL 4.DIV 5.EXIT

read op

case $op in

1) echo addition=` expr $a + $b `;;

2) echo subtration=` expr $a - $b `;;

3) echo multiplication=` expr $a \* $b `;;

4) echo division=` expr $a / $b `;;

5) break;;

*) echo invalid choice

esac

OUTPUT:

CS6413 OPERATING SYSTEMS LABORATORY


G.BHARATH KUMAR 411615104004

[oslab@localhost ~]$ sh airthmetic.sh

Enter two numbers 10 20

1.ADD 2.SUB 3.MUL 4.DIV 5.EXIT

addition=30

[oslab@localhost ~]$ sh airthmetic.sh

Enter two numbers 20 10

1.ADD 2.SUB 3.MUL 4.DIV 5.EXIT

subtration=10

[oslab@localhost ~]$ sh airthmetic.sh

Enter two numbers 5 2

1.ADD 2.SUB 3.MUL 4.DIV 5.EXIT

multiplication=10

[oslab@localhost ~]$ sh airthmetic.sh

Enter two numbers 16 2

1.ADD 2.SUB 3.MUL 4.DIV 5.EXIT

division=8

PROGRAM:

CS6413 OPERATING SYSTEMS LABORATORY


G.BHARATH KUMAR 411615104004

echo "Enter a number"

read num

i=1

fact=1

while [ $i -le $num ]

do

fact=` echo $fact \* $i|bc `

i=` expr $i + 1 `

done

echo "Factorial value of $num is $fact"

OUTPUT:

[oslab@localhost ~]$ sh fact.sh

CS6413 OPERATING SYSTEMS LABORATORY


G.BHARATH KUMAR 411615104004

Enter a number

Factorial value of 5 is 120

CS6413 OPERATING SYSTEMS LABORATORY


G.BHARATH KUMAR 411615104004

PROGRAM:

echo enter the basic salary

read basic

da=` echo $basic \* 20 / 100 | bc `

hra=` echo $basic \* 10 / 10 | bc `

gs=` echo $basic + $da + $hra | tee a | bc `

echo gross salary= Rs $gs

CS6413 OPERATING SYSTEMS LABORATORY


G.BHARATH KUMAR 411615104004

OUTPUT:

[oslab@localhost ~]$ sh gross.sh

enter the basic salary

5000

gross salary= Rs 11000

CS6413 OPERATING SYSTEMS LABORATORY


G.BHARATH KUMAR 411615104004

PROGRAM:

echo "Enter the number"

read num

sum=0

while [ $num -gt 0 ]

do

d=` expr $num % 10 `

num=` expr $num / 10 `

sum=` expr $sum + $d `

done

echo "Sum of Digits is $sum"

CS6413 OPERATING SYSTEMS LABORATORY


G.BHARATH KUMAR 411615104004

OUTPUT:

[oslab@localhost ~]$ sh sum.sh

Enter the number

143

Sum of Digits is 8

CS6413 OPERATING SYSTEMS LABORATORY

También podría gustarte