Skip to content

Instantly share code, notes, and snippets.

@chilismaug
Created July 10, 2016 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chilismaug/0c43108187654a3cf1bfd8b1170faf6f to your computer and use it in GitHub Desktop.
Save chilismaug/0c43108187654a3cf1bfd8b1170faf6f to your computer and use it in GitHub Desktop.
bash prepend a header file into a file
assuming that the file you want to edit is my.txt
$cat my.txt
this is the regular file
And the file you want to prepend is header
$ cat header
this is the header
Be sure to have a final blank line in the header file.
Now you can prepend it with
$cat header <(cat my.txt) > my.txt
You end up with
$ cat my.txt
this is the header
this is the regular file
As far as I know this only works in 'bash'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment