1

INPUT:

* * * * * ( /path/to/foo -x )
3 * * * * /full/path/tothing
3 3,2,4 * * * /full/path/tothing4 3

OUTPUT:

( /path/to/foo -x )
/full/path/tothing
/full/path/tothing4 3

Q: How can I truncate the line until the fifth space?

0

Here's a way:

$ crontab -l|sed -r 's/([^[:space:]]+[[:space:]]){5}//'
2

Using cut:

crontab -l | cut -d' ' -f6-
  • it's not deleting any zero, it's an range of field value , you can test using echo "1 2 3 4 5 6 bla bla " | cut -d' ' -f6-0 – Rahul Patil Oct 11 '13 at 10:14
  • might be you have copied wrong, please type that command manually and see – Rahul Patil Oct 11 '13 at 10:18
  • both working in my system.., So I have updated that last one – Rahul Patil Oct 11 '13 at 10:24
0

Try:

cat /etc/crontab|awk '{ print substr($0, index($0, $7)) }'

This will print each line without the 6th field.

  • Use $6, not $7... – mr.spuratic Oct 11 '13 at 9:10
  • it's a very bad idea, because the commands could have spaces, I updated the Q, ty! – gasko peter Oct 11 '13 at 9:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.