Replacement with sed or awk
Hello I am making a daemon in shell to execute several commands depending on the date and time on the server and on the date and time I have assigned for every command to be executed. The file where I have this info looks like this:
enable min hour day month year command
1:10:11:14:2:2009:echo "Feliz dia de San Valentin!"
1:20:14:1:5:2009:echo "Feliz dia del trabajo"
1:10:19:04:08:2009:banner Daemon 'funciona!!'
If the date and time of the server is the same than the date and time of any of the registers, the command will be executed. The problem is that it will keep executing it as long as the date and time matches, Thats why I have placed an enable flag in the beginning of every register. When the command is executed it has to turn off the enable flag, I don't know how to do this in a single sed or awk instruction, can anyone please tell me?
I have tried this:
i is a variable wich has the line number of the register I want to disable.
a=`sed -n "$i,$i"p`
b=0`echo $a | cut -c 2-100`
sed s/$a/$b/g file
I just need to know how to get sed to replace the variables a and b but I don't know how to tell sed not to interpret the meta characters inside the variables.
Last edited by DeepSeaNautilus; 08-04-2008 at 09:49 PM.