Hi All,
I want to read one number from the file.
Only one number will be there in the file.
then i have to increment the number in my script and put it back in the same file.
Is it possible?
Can anybody help me?
Thanks,
Vinay
Hi All,
I want to read one number from the file.
Only one number will be there in the file.
then i have to increment the number in my script and put it back in the same file.
Is it possible?
Can anybody help me?
Thanks,
Vinay
Something like this?
awk '$0++' file > newfile && mv newfile file
Regards
Hi Franklin,
I want to place the incremented value in the same old file.
say my file name is "file.txt" which has number 5 in it.
once i run the script, this value should be taken and 6 should be placed in the file "file.txt".
I think you got my requirement.
Thanks
Vinay
-----Post Update-----
Hi Franklin,
It is working fine.
Thanks a lot...
Regards
Vinay
Vinay,
Try this code:
read i < a
i=`expr $i + 1`
echo $i > a
cat a
It is working perfectly fine in bash.
Here "a" is a file name where the number is stored & "i" is a temp variable.
Let me know if you need any more info.
Hi Dcoolsam,
Thanks a lot ,,,,
Your code suits my requirement.
But one change is needed, here it is printing the number also in echo line...
i dont want to print that,,,
how can i fix it...
Regards
Vinay
Hey Vinay,
Your task is getting accomplished by just first 3 lines of my code.
Last line is just to print that value.
You can remove that last line : cat a
You check the incremented value in the file.
It will be incremented.
Cheers....
Hi Dcoolsam,
Yes i checked. It is working properly.
Thanks a lot,,,,
Regards,
Vinay