How can I write some lines to a file in a bash script?
I want to write the following into a file ~/.inputrc
"\e[A": history-search-backward
"\e[B": history-search-forward
"\e[C": forward-char
"\e[D": backward-char
Currently I have this working but somewhat ugly method, and I’m sure there should be a better way.
#!/bin/sh
echo \"\\e[A\": history-search-backward > ~/.inputrc
echo \"\\e[B\": history-search-forward >> ~/.inputrc
echo \"\\e[C\": forward-char >> ~/.inputrc
echo \"\\e[D\": backward-char >> ~/.inputrc
A slightly simpler method would be:
I’m curious why you need to do this though. If you want to setup a file with some specific text, then maybe you should create the skeleton file, and dump it into
/etc/skel. Then, you cancp /etc/skel/.inputrc ~/.inputrcin your script.