Describe expr statement with example.

1 Answer

Answer :

The expr command is used to evaluate an arithmetic expression from the command line. 

The expr command can be used to perform arithmetic operations, comparison operations and string operations. The following table specify the way how to use the different operators with expr command in shell and their meaning. Most of the operators are escaped with backslash as these operators are shell built in operators and having specific meaning for example < and > are redirection operators. 

Syntax: expr operator value2


Example :

$ expr 1 + 2

3

$ expr 5 \* 2

10

$

$ y= ‘expr 7+9’

$ echo $y

16

$ a=10; b=17

$ c=’expr $a * $b’

$ echo $c

170

$ expr 5 “*” 10

50


Related questions

Description : Describe Chmod command with example. 

Last Answer : In Unix-like operating systems, the chmod command sets the permissions of files or directories. On Unix-like operating systems, a set of flags associated with each file determines who can access that file, and how ... stands for "write", 1 stands for "execute", and 0 stands for "no permission."  

Description : Describe working of RAID-0 and RAID-1 with suitable example.

Last Answer : RAID 0 (Striped Disk Array Without Fault Tolerance):  This level strips the data into multiple available drives equally giving a very high read and write performance but offering no fault tolerance or redundancy.  ... No. of Disk: 2 Size of each disk: 100GB Usable Disk size: 100GB

Description : Describe working of diff and cmp file handling commands with example.

Last Answer : Diff command: diff stands for difference. This command is used to display the differences in the files by comparing the files line by line. it tells us which lines in one file have is to be changed to make the two files ... $ cat file1 abcd xyz $ cat file2 Abed wxy $_  

Description : Describe cat and rm file handling commands with example.

Last Answer : cat Command: Cat(concatenate) command is very frequently used in Linux. It reads data from the file and gives their content as output. It helps us to create, view, concatenate files. cat is ... and will delete all the files and sub-directories recursively of the parent directory. $ rm -r 

Description : Describe use of following commands with example: i) route ii) net stat

Last Answer : Route: Packets are transmitted from one computer to another. The route determines where the process starts and what computer system needs to send the packet for it to reach its destination. In ... or softwaredefined network interface) and network protocol statistics. Options of Netstat: