Using ‘echo’, it's easy to append to a file:
--------------------------------------------------------------------------------
$ echo "// vim: set tw=80 syntax=sh:" >> ~/.bashrc
--------------------------------------------------------------------------------
But how do you do it the other way around..? Prepend to a file so-to-speak..?
I saw a couple of threads in stackoverflow.com with complicated one-liners and
everybody appeared to conclude that you need a temp file anyway..
So how about:
--------------------------------------------------------------------------------
$ echo -e "$(echo -e "// vim: set tw=80 syntax=sh: ";cat ~/.bashrc)" > ~/.bashrc
--------------------------------------------------------------------------------
- how does it work..? Namely why isn't the file overwritten..?
- barring a power failure while running.. could this cause data loss..?
- is there a portable way to do it with printf..?
Just curious.. Even for one character, I would fire up an editor.
CJ
--
Focus follow mouse users will burn in hell!!!