I would like to use this script with the intention of replacing all instances of the letter Q within a file with the contents of the file "question.txt". Instead what happens is that all the instances of Q in the file disappear and the contents of "question.txt" are printed at the bottom of the new file.
Any ideas?
sed -i.bkp '/Q/{
s/Q//g
r /Users/ericbrotto/Desktop/question.txt
}' Commision.txt
EDIT 1
I'm trying to find out what version I have, but keep on getting this:
Best Answer
I guess I found the reason why.
If I put some blank after the filename, a filename with trailing blanks is searched. I can reproduce the problem this way:
Sources:
Working example with filename 'kuh.dat':
Now the failing example, with 'kuh.dat '.
Since the filename isn't quoted, it is a great surprise for me, that the blank at the filename-end is recognized. And it isn't visible in the shell, so I searched for a long time without success, where the difference between the two examples is.