Why can't I use echo $1 > /sys/class/backlight/acpi_video0/brightness in a simple bash script?

It gives me the error: echo: write error: Invalid argument.

link|improve this question
feedback

2 Answers

Try echo "$1" > /sys/class/backlight/acpi_video0/brightness.

I bet the shell is expanding $1 and thus echo thinks it is receiving a bunch of arguments, rather than a string.

link|improve this answer
feedback

You should check what the actual value of $1 is. This error means you are trying to write an invalid value -- either it's out of range or just in general not a meaningful value.

At a glance, it appears that it accepts an integer in the range 0 to 8 (for me at least).

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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