Created
September 16, 2015 18:33
-
-
Save bltavares/358ad620f883f676c749 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'shellwords' | |
def escape(s) | |
Shellwords.shellescape(s) | |
end | |
entry = '' | |
entry_escaped = entry.gsub(/\*/, '\\*').gsub(/\[/, '\\[').gsub(/\]/, '\\]') | |
grep_command = "grep -v '^[[:space:]]*#' | grep -- ^#{escape(entry_escaped)}$" | |
user = 'root' | |
puts "crontab -l -u #{escape(user)} | #{grep_command}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment