0
jaime@OpticaOmegaPlus:~$ echo 'date %T' >/tmp/midate; chmod rx /tmp/midate; /tmp/midate
chmod: invalid mode: ‘rx’
Try 'chmod --help' for more information.
-bash: /tmp/midate: Permission denied

Could someone tell me why it does not work

1 Answer 1

3

You're doing it wrong.

$ echo 'date +%T' >> /tmp/Temp_date && chmod +rx /tmp/Temp_date && /tmp/Temp_date
08:32:18
  • You need to add + sign before rx.
  • You need to add + sign before %T to ensure it recognized by date.
  • With all command fail, meaning you have not add content to file named midate on /tmp, that's why bash refuse to execute. As it was not valid script.
6
  • Can we be sure the OP intended +rw (rather than =rw for example)? Also AFAIK space after the redirection operator is optional. Apr 10, 2019 at 1:56
  • Yes, that maybe true.... we'll just wait for OP to inform us what he want.
    – Liso
    Apr 10, 2019 at 2:03
  • @steeldriver does that mean redirection with or without space produce the same result? I'm sorry, I don't know much about bash script etc..
    – Liso
    Apr 10, 2019 at 2:03
  • Yes it should produce the same result - did you try it? Apr 10, 2019 at 2:11
  • Well that seems the case ! Im gonna edit my answer now, thanks for pointing out @steeldriver
    – Liso
    Apr 10, 2019 at 2:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .