The text file manipulation is one of the most common job for a system administrator, today I'm going to show how to insert a string at the beginning of each line in a text file.

The problem:
we have a file named file0.txt and we want to add the string "text to add at the beginning"  at the beginning of each line of this file.

shell1we want an output like the following:

1 – The awk

awk can do almost everything on text files, here you are the awk solution for our problem, this sites has a lot of example of text files manipulation using awk.

2 – Sed, the other side of the moon

3 – perl scripting language

4 – line numbering filter

See you soon