0

I am new to bash and I am creating a program that will allow a user to manage crontab with a user interface. I want to create an option to select a cron task. I have it listing a number before the task but I want to be able to select an individual line by typing the line number. EG it will look like:

0 * * * * mkdir TEST

.@reboot echo RESTART

etc..

SELECT 1

0 * * * * mkdir TEST (This is the part where you are allowed to edit the task)

How would it be possible to achieve this.

Here's my code so far:

if [[ $INPUT == "3" ]]; then
      echo "Here is the current crontab entries:"
      crontab -l | awk '{ print NR ". " $0 }' 
      read -p "Please select a task: " TASKSELECT

That is as far as I have got with that part and I'm not too sure how to proceed. I assume it can be achieved by selecting the crontab file and searching for the line number or something.

tripleee
  • 175,061
  • 34
  • 275
  • 318

0 Answers0