In the context of adding the same lines at end of the .bashrc or .vimrc files of several user accounts on the same machine, what would be an easy way to copy the last n-lines from one shell script to another?


1 Answer 1


Since jasonwryan hasn't turned their comment into an answer, I'll put this here just to close the question. If you prefer one of the answers from Wildcard's link instead, we can close this Q as a duplicate.

for dest in file1 file2 file.3rd
  tail -n 5 /path/to/source/file >> "$dest"

...where 5 is the number of lines to grab. I put a loop around it just to demonstrate one way to do it -- you could put a glob there instead (/home/userx*/.bashrc for example).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .