Add a string to the end of each line in Linux

You have to love Linux ! There are things you can do in Linux that you don’t even dare to try in Windows :), don’t get me wrong my P.C. and my Laptop run on top of Windows but i spend most of the time logged on to a Putty terminal.

So. why this issue ?!

I am migrating some data out of SQL Server and i ma using the sqlcmd(much faster then using the GUI).

  • the problem is  that sqlcmd is quite limited when you try to export the data and apply a line terminator , apparently the -r option is not working.

  • so after exporting a table with 20 millions rows (about 12 Gb of data) i had to edit the file so i can add a semi-column a the end of each line. How do you do this in windows ? You don’t ! You might use NotePad++ but you Laptop will “crash” – windows cannot handle big files.:(

 So the solution is simple and is called Linux

I had to copy the exported file onto my Linux host and run a simple command on top if it.

  • so i just run a sed command specifying my line terminator string as ‘;’.

ohhhh another thing this was about 100 times faster done in linux then if i would do it in Notepad++ running on windows.

 

   

I hope this was helpful and i appreciate if you would like, subscribe or share our posts. I it is just a click

clickhere

Similar Article  Easy way to export data from csv files in MySQL
No Comments
Leave a Comment

%d bloggers like this: