beakr
beakr

Reputation: 5867

Shell: read a file and echo it's contents to another file

I have a Makefile that is supposed to echo aliases from another file to your local .zshrc file.

I need to read the contents of the file aliases.sh, and echo it's contents to ~/.zshrc, how is this possible?

Upvotes: 19

Views: 31782

Answers (2)

Wallis Short
Wallis Short

Reputation: 9

Depending on permissions, I prefer the following:

$cat aliases.sh | sudo tee ~/.zshrc

If you dont want to overwrite the contents on the destination file use the -a.
This option tells tee to append to the given file instead of overwriting it.

$ cat aliases.sh | sudo tee -a ~/.zshrc

Upvotes: 0

Ankur
Ankur

Reputation: 33657

cat aliases.sh >> ~/.zshrc

Upvotes: 33

Related Questions