How to insert special characters at the beginning or end of each line in Linux

How to insert special characters at the beginning or end of each line in Linux

Hello Everyone, in this post we will see how to insert a some text or special characters at the beginning or end of  a multi-line file in Linux. Its really helpful when we have a file with more than 1000 lines or so.

Just open the terminal and open the file using vim editor.

Here we have a sample file having few email id’s per line,

screen-1

 

 

 

 

  

Now Suppose we want to insert a special character for example  at the beginning of each line, we can simply achieve it with a single command as shown below:

screen-2

 

 

 

 

  

When we’ll run this command, it will insert  at the beginning of each line.

screen-3

 

 

 

 

 

 Similarly to insert at the end of each line we can use below command:

screen-4

 

 

 

 

  

This Command will insert ‘, at the end of each line as shown below:

screen-5

 

 

 

 

   

Now Simply Save it & Enjoy 🙂

Leave a Reply

Time limit is exhausted. Please reload the CAPTCHA.