Skip to main content
added 77 characters in body
Source Link
ctrl-alt-delor
  • 28.8k
  • 11
  • 66
  • 113

Yes you see the problem (your answer https://unix.stackexchange.com/a/481424/4778), but you still must quote the $1 (just in case). And don't forget to specify the interpreter (#!…)

#!/bin/bash
sudo sh -c 'echo '"$1"' > /sys/class/backlight/intel_backlight/brightness'

«solution removed, as it does not quote properly, and has a security bug. see @Kusalananda answer.»

We can concatenate strings by touching them together. Double quotes will expand $ expressions, but single will not. In this case you could have put it all in a double quote, as the rest of the text has no $s, so it makes no difference.

Yes you see the problem (your answer https://unix.stackexchange.com/a/481424/4778), but you still must quote the $1 (just in case). And don't forget to specify the interpreter (#!…)

#!/bin/bash
sudo sh -c 'echo '"$1"' > /sys/class/backlight/intel_backlight/brightness'

We can concatenate strings by touching them together. Double quotes will expand $ expressions, but single will not. In this case you could have put it all in a double quote, as the rest of the text has no $s, so it makes no difference.

Yes you see the problem (your answer https://unix.stackexchange.com/a/481424/4778), but you still must quote the $1 (just in case). And don't forget to specify the interpreter (#!…)

«solution removed, as it does not quote properly, and has a security bug. see @Kusalananda answer.»

We can concatenate strings by touching them together. Double quotes will expand $ expressions, but single will not. In this case you could have put it all in a double quote, as the rest of the text has no $s, so it makes no difference.

Source Link
ctrl-alt-delor
  • 28.8k
  • 11
  • 66
  • 113

Yes you see the problem (your answer https://unix.stackexchange.com/a/481424/4778), but you still must quote the $1 (just in case). And don't forget to specify the interpreter (#!…)

#!/bin/bash
sudo sh -c 'echo '"$1"' > /sys/class/backlight/intel_backlight/brightness'

We can concatenate strings by touching them together. Double quotes will expand $ expressions, but single will not. In this case you could have put it all in a double quote, as the rest of the text has no $s, so it makes no difference.