Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to create a script that insert 20 characters following each line in a text file.

Suppose the file contains the following lines:


I want to obtain:

------(20 symbols)
------(20 symbols)
------(20 symbols)

How to do this?

share|improve this question
Actually I wanted to obtain after that a modified filed, with the contant shown above. Thanks much – yyyzzz Oct 6 '13 at 17:44
Sorry, I cannot understand. Perhaps you mean you want to modify the file inplace? – Andrea Corbellini Oct 6 '13 at 17:46
up vote 1 down vote accepted
while read line
    echo "$line"
    echo "characters"
done < input > output

Where input is the source file and output is the destination file.

If you want to input and output to be the standard input and output respectively, then replace done < input > output with just done.

share|improve this answer
Thank you much!!!! – yyyzzz Oct 6 '13 at 17:53

One way (there are many) is using the sed append command

sed 'a\
Extra twenty characters
' myfile

If this is for homework, you should consider what your class is about and what you are supposed to be learning, and select the most appropriate answer based on that

share|improve this answer
... you should consider what your class is about ...: +1. I though this was a pure-shell question, but I could be wrong. – Andrea Corbellini Oct 6 '13 at 17:44
Thank you! Can you please tell me how this will apend text after each line of text file? Thanks much in advance! – yyyzzz Oct 6 '13 at 17:45
No, that is not homework :) I am getting used to Linux environment – yyyzzz Oct 6 '13 at 17:47

If input file is Hugh then you could use awk to perform it faster..

awk '{print $0,"\ntype your symbols here "}' input > output
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.