Learning Bash

Credits
13
Dear All, I am learning bash and trying to find out the way each time I run the script it should show me the date when i first made that script(or learned that command). I don't want to put the date manually.

is there any way I can store the value of today after running the bash and it gives me the message as 'Welcome, you learned this on SO and so date earlier'

if you can help me in understanding the basics of this pls?
 


dcbrown73

Well-Known Member
Credits
2,836
Am I understanding correctly that you want to store data (persist data) in the body of a script so that it prints it out without manually setting that data (hard coding it) in the script?

That is a sketchy request. Scripts usually do not write to themselves, so you must store that data externally. For instance, say I have a script called myscript.sh. I could also create a datafile called myscript.dat and myscript.sh can write the time / date or whatever to the myscript.dat.

Then later when you execute the script, it can read from myscript.dat and display the data. Or of course, you can also read / write to sqlite database or whatever other storage engine you want to use providing you can access it via a Bash script.

I hope that helps.
Dave
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Members online


Top