Time based script
Hello,
How can I make a script which will run every day at 3 oclock, and will modify content of one specific file. The modify script must be like this: Edit a txt file, check for timestamp and replace it with today's timestamp How can I make this kind of modify script? |
You'd first want to check out the `cron` feature -- it lets you run a script or command at a specified time/interval (every Wednesday at 4pm, or every 7 minutes, or almost whatever configuration you'd like).
As for the script itself, what have you tried so far, and in what programming/scripting languages (including sed)? |
Regarding sed, I tried with this:
Shell script: #!/bin/bash TODAY=$(date +%D) echo $TODAY sed -s ??? file The sed is bothering me :( |
you can use bash script according to your distro and/or perl if you have programming skills.
|
I do not have a good programing skills.
Right now, all I need is to replace first line in my file with a my string. How can this be done with sed? The file test.txt looks like this tee teee2 dfsds ddddd How can I use sed, to edit the file and replace the first line with "bbbb"? |
I've got it:
#!/bin/bash sed -i -e "1c\\#`date`" test.txt |
All times are GMT -5. The time now is 08:11 PM. |