I am an unleet unhaxor

Discuss Programming
Post Reply
X11
guru
guru
Posts: 676
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia
Contact:

I am an unleet unhaxor

Post by X11 »

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

User avatar
Void Main
Site Admin
Site Admin
Posts: 5716
Joined: Wed Jan 08, 2003 5:24 am
Location: Tuxville, USA
Contact:

Post by Void Main »

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

X11
guru
guru
Posts: 676
Joined: Sun Jan 19, 2003 11:09 pm
Location: Australia
Contact:

Post by X11 »

Cool thnaks, im writing a CMS in shell scripts FYI.

Post Reply