expr in shell programming


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting expr in shell programming
# 1  
Old 11-30-2007
expr in shell programming

i am new to shell programming, currently using redhat linux of version
2.4.20-8.
i have problem in executing expr command in the following shell script

$ x=5
$ x='expr $x + 1'
$ echo $x

the output is displaying always
expr $x + 1

Pls guide me for the above query
# 2  
Old 11-30-2007
Use

`expr $x + 1`

use the symbol on that is on "~" on your key board
# 3  
Old 11-30-2007
I prefer to avoid "expr":

Code:
x=5
((x+=1))
echo $x

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell Programming

Hi, I am using two files - one file contains list of service name , other file contains commands for each of these service name . I have to read each service name and check this string in 1.cfg file , if it exists , then i have to read another file (commands file ) and take the string and... (2 Replies)
Discussion started by: santhoshks
2 Replies

2. Shell Programming and Scripting

Help with shell programming

1)Shell program which displays a list of all files in the current directory to which you (other than owner and group) have only read and execute permission. 2)Shell program which deletes all the lines containing the word 'UNIX' in the files supplied as arguments to this program. 3)Shell... (1 Reply)
Discussion started by: Ramanath
1 Replies

3. UNIX for Dummies Questions & Answers

Shell script to read lines in a text file and filter user data Shell Programming and Scripting

sxsaaas (3 Replies)
Discussion started by: VikrantD
3 Replies

4. Shell Programming and Scripting

Problem with expr command in shell script

Hi, I have used expr command to increment the date. for e.g., case 1 : echo $(date -d $(echo `expr 20010101 + 1`)) it returns Tue Jan 2 00:00:00 IST 2001 case 2: echo $(date -d $(echo `expr 20010101 - 1`)) it returns date: invalid date `20010100' please suggest me, how to... (3 Replies)
Discussion started by: nanthagopal
3 Replies

5. Shell Programming and Scripting

Shell Programming

Hi ULF, Good day! Let's say I have an input file similar to this one below: content-type 699 label SAMPLE1 pattern ip-address host 10.10.10.10 host 12.12.12.12 end udr udr-type TEST ... (2 Replies)
Discussion started by: rymnd_12345
2 Replies

6. Shell Programming and Scripting

SHELL PROGRAMMING

Using shell scripting, implement ‘scan.sh' that scans the file system recursively starting from current working directory and generates the file ‘index.txt' that contains a line for each file (or directory) with following fields in tab separated format: 1. The full path of the directory... (1 Reply)
Discussion started by: kranthikiran
1 Replies

7. Shell Programming and Scripting

test expr VS [ expr ]

What is the difference between test expr VS . For example : if test 5 -eq 6 echo "Wrong" and if echo "Wrong" bot will give the same output as Wrong. Now, what is the difference between these two? though they are producing the same result why we need two? Any answer will be... (2 Replies)
Discussion started by: ashok.g
2 Replies

8. Shell Programming and Scripting

{} in shell programming

Could someone please tell me what {} mean when they surround a variable? For instance, $FILE = 'basename $1' //what is passed into this script $BANK = 'dirname $1' $INFILE = ${FILE}.${BANK}.$$ What does $INFILE contain after this assignment? Please let me know Thanks G (4 Replies)
Discussion started by: vgirijanaidu
4 Replies

9. UNIX for Dummies Questions & Answers

Shell Programming Help

Hi, I am new to shell programming, and hve been given a request to write a shell script. Is there any good places to go to see examples of how to write shell programming scripts? Thanks (4 Replies)
Discussion started by: mec585858
4 Replies

10. UNIX for Dummies Questions & Answers

Shell Programming

I have a fix_table.ksh script that takes a TABLENAME and a date. So, in jk_table_file.txt I have the tables...one per line, and in jk_out_file.txt I have the date in the format I need. The following doesn not 'want' to work in a shell script... for TABLE in `cat jk_table_file.txt`; do ... (2 Replies)
Discussion started by: JWK1
2 Replies
Login or Register to Ask a Question