Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340
Rep:
Converting a paragraph into a one-line string
Suppose I have 2 paragraphs of text such as: "hello world 1
hello world 2
hello world 3"
linux rules 1
linux rules 2
linux rules 3"
and i want to convert each paragraph into a one line string such as "hello world 1, hello world 2, hello world 3" and "linux rules 1, linux rules 2, linux rules 3" (delimited by commas). I did it using a C program by detecting "/n" characters. But, honestly, I'd like to do it using a simple bash script - i know dat it can be done cos i've made it once, but i just cannot remember how i've done it.
Moreover, how can i control the size of a file, in a similar way as logrotate does? - i have this file here which i continusouly append data to it, but only the 50 recent entries are needed... Or for assurance, the last 100 entries, to be on d safe side that all previous entries have been processed.
Distribution: RH 7.3/8.0/9.0, Debian Stable 3.0, FreeBSD 5.2, Solaris 8/9/10,HP-UX
Posts: 340
Original Poster
Rep:
Thanks jkobrien,
it worked for that particular example of having two paragraphs.
Now i hope to get it work as a general case since i simplified my problem - I have a big log file (i.e. with more than two paragraphs) where each record is displayed as a paragraph. The paragraphs are seperated by a blank line. In order to process the data, I need to convert the file such that each paragraph is displayed as a line...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.