Adding lines to each block in a multicolumn text file
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
My New Line My New Line My New Line
g51/b18468 Postgg On 30/05/2013 N51/b39897 Postgg On 30/05/2013 LR51/b23428 Postgg On 30/05/2013
Rgv. XXXXX Mr. bBnMbNNbN.M Bro. bBRbgbM .S,
KbgbNg bSSgMBLY Og gOg, LOT 92, KbMPUNg gRbgg gOMMUNnTY ggNTRg,
52, gLN. TnMUR, BbTU 4, 43950 4, LORONg SS 23/6g,
POST BOX 20, 43007 KbgbNg SUNgbn PgLnK 47400 PgTbLnNg gbYb,
MbLbYSnb SgLbNgUR SgLbNgOR, W.MbLbYSnb
for all addresses ofc while maintaining same formatting. I dont know how to achieve this. Can you guys help me out with this?
In which word processor or programming language are you planning to accomplish this? What have you tried so far?
If every address field has the same height and width, including the blank padding below and to the right of each address, you don't even have to do anything sophisticated like searching for patterns. You could just write a word processor script (or macro) to repeatedly count lines and insert the new text. The new text would not be
By the way, I have suggested a way to handle this as a one-time problem. If you plan to maintain this address list and modify it in the future, you really should rearrange it into one column or some other structure or database that will make your future work easier.
The input and output separators have been set to three contiguous newlines, and each record is simply prepended with the desired string and then printed. I used variables for the string and padding spaces just to compact things a bit.
It could probably be done somewhat cleaner with printf instead, but this works well enough.
Finally, I agree with Beryllos. Lists of database-style entries are easier to manipulate if each record is kept separate.
stevanity, It appears that your sample text is a substitution cipher. Before we all have some fun cracking it, I need to ask you if it is important for reasons of privacy or security to keep the names and addresses secret. If so, you should delete them.
Well, a full explanation really requires understanding something of how awk works. Check out the links below.
But in brief, awk divides the input into records, and then further subdivides the records into fields. By default a record is a line, and a field is a word, but this can be changed. RS is the input record separator variable, which I set to match three consecutive newlines. ORS is the output record separator, which needs to be set to the same as the input if you want to keep the same formatting.
$0 refers to the current record as a whole. So the command just re-sets it to be equal to the new line plus itself, then prints it.