I think he was trying to guess the syntax and used
Tcl's.
By the way, you should check what the user input is before processing it.
What if it's «
. » for example? It'll clear everything since it represents a character.
Tricky task, I know.
What about the following?
Code:
sed -i "\,$(printf %q "${inputbyuser//./\.}"),d" /etc/crontab
I think it suffices. It's not completely safe though.
EDIT:
Improved to keep dots.
Code:
tmp=$(printf %q "${inputbyuser//./\.}")
inputbyuser=${tmp//\\\\/\\}
sed -i "\,${inputbyuser},d" /etc/crontab
EDIT (2):
Code:
tmp=$(printf %q "${inputbyuser//./\.}")
inputbyuser=${tmp//\\\\/\\}
sed -i \\$'\10'"${inputbyuser}"$'\10'd /etc/crontab
I think it should be good now.