| Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free! |
Shell script help
|
Original Message
|
Name: AndrewG1976
Date: July 28, 2005 at 21:12:10 Pacific
Subject: Shell script helpOS: SunOS 5.8CPU/Ram: 440Mhz/512MB |
Comment: Hi, I'm new to shell scripting (ksh). I have a file called buildnumber.txt that has the value 1 inside it: #cat buildnumber.txt 1 I need to write a shell script called "buildnumber" that takes the value from buildnumber.txt as a variable and increases the value in buildnumber.txt by 1. Can anyone help?
Report Offensive Message For Removal
|
|
Response Number 2
|
Name: AndrewG1976
Date: July 28, 2005 at 22:19:35 Pacific
|
Reply: (edit)Thanks. I removed the following line: (( NUM = NUM+1 )) as this only increased the value for NUM by 1 in the output. What I need to do is increase the value in buildnumber.txt by 1. How can I do this?
Report Offensive Follow Up For Removal
|
|
Response Number 3
|
Name: cislord
Date: July 28, 2005 at 23:23:06 Pacific
|
Reply: (edit)Sorry, I misread your post. All you have to do is direct the output to buildnumber.txt. That is: #!/bin/ksh # declare NUM as type integer typeset -i NUM cat buildnumber.txt | read NUM (( NUM = NUM+1 )) echo $NUM > buildnumber.txt
Report Offensive Follow Up For Removal
|

Post Locked
This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
Go to Unix Forum Home