I am an unleet unhaxor

Discuss Programming

I am an unleet unhaxor

Postby X11 » Fri Jul 11, 2003 9:27 pm

I cant work this out, im sure someone here can...

What I want is for a script to read a number from a file (the file will contain nothing else, just that number) then it increments it by 1 and writes it to the file, this is what I thought it would be...

number=$(cat number) # Get number
number=($("article_number$")+1) # Increment number
echo "$article_number" > number # Write number

Im sure im close, I actually dont know anything about reading from files, I think you do it somthing like that
X11
guru
guru
 
Posts: 674
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia

Postby Void Main » Fri Jul 11, 2003 10:39 pm

Code: Select all
num=`cat number.txt`
((num=num+1))
echo $num > number.txt


or

Code: Select all
expr `cat number.txt` + 1 > number.txt
User avatar
Void Main
Site Admin
Site Admin
 
Posts: 5705
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA

Postby X11 » Fri Jul 11, 2003 10:46 pm

Cool thnaks, im writing a CMS in shell scripts FYI.
X11
guru
guru
 
Posts: 674
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia


Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests

cron