Results 1 to 2 of 2
Hi All,
I am new to scripting. i am creating a script by which it will check all the entries in crontab and print all the enteries start with # ...
- 10-13-2008 #1Just Joined!
- Join Date
- Jan 2008
- Posts
- 20
removing # in crontab (bash script)
Hi All,
I am new to scripting. i am creating a script by which it will check all the entries in crontab and print all the enteries start with # and after that it will remove # if any entry will be commented. Please help me to resolve out.
For exp :-
$crontab -l
#*/10 * * * * ./aa.sh
* * * * * ./bb.sh
# * * * * * ./cc.sh
i want first it print "ok" if # is present at the beginning of the line and then
I want to remove #
And please let me know how can i remove # in crontab through a script. so that the crontab -l should like this :-
*/10 * * * * ./aa.sh
* * * * * ./bb.sh
* * * * * ./cc.sh
Please help me.
Thanks in advance
Inder
- 10-14-2008 #2
I'm afraid I don't entirely understand.
If we imagine that crontab -l looks like:
You want the output to be:Code:#*/10 * * * * ./aa.sh * * * * * ./bb.sh # * * * * * ./cc.sh
?Code:ok */10 * * * * ./aa.sh * * * * * ./bb.sh ok * * * * * ./cc.sh
In any case, checking if a line starts with a '#' can be easily accomplished with sed if you want to use it, or grep if you want to just check within the script. The regular expression is "^#", where '^' indicates the beginning of the string, and the '#' is a literal '#'.DISTRO=Arch
Registered Linux User #388732


Reply With Quote