18

I want to explain to some friends how to add multikey support to their linux systems at bootup but first I need them to make a bash script. I want to make a simple command for them to copy and paste and I'm testing out this command I made but it keeps throwing an error. Only when I add the shebang line which, well is important.

$ sudo echo -e "#!/bin/bash \nxmodmap \"keysym Alt_R = Multi_key\"" > /etc.init.d/multikey.sh

Any easy way to echo a shebang line?

Chris Eberle
  • 47,994
  • 12
  • 82
  • 119
Isaiah
  • 1,995
  • 2
  • 18
  • 29

2 Answers2

37

Use the other quotes.

sudo echo -e '#!/bin/bash\nxmodmap "keysym Alt_R = Multi_key"'
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
16

If you want to impress your friends use here documents not echo strings :-)

~$ cat << EOF > /etc/init.d/multikey.sh
> #!/bin/bash          
> xmodmap "keysym Alt_R = Multi_key"
> EOF
hmontoliu
  • 3,960
  • 1
  • 19
  • 21