I don't really know what I'm doing with that sed command; it's just showing my thought process as to what I want to achieve.
Input example is a blob of text with periods (.) marking sentences. The following output example would have random \n\n breaks, between every random 3 - 6 periods (for example):
Moderator's Comments:
Please use CODE tags for all sample input, sample output, and code segments (as required by forum rules).
Last edited by Don Cragun; 07-21-2016 at 12:12 AM..
Reason: Add CODE tags.
Thank you RudiC, that is awesome! I see what you did here
as rand() is between 0 and 1 (so between 5 and 5*2 periods). I can adjust values to create new ranges. T (or a) is array field of split().
Yes, split($0, %, ".") creates an array named T with each element of T[] containing the text between periods in the input line. If you'd like to get rid of leading whitespace characters at the start of each paragraph, you might want to consider this slight modification of RudiC's suggestion:
If you'd like to try this on a Solaris/SunOS system, change awk to /usr/xpg4/bin/awk.
Note that on some versions of awk neither of these suggestions will work if the single-line input file is longer than 2048 bytes (or whatever the command:
returns on your system if it isn't 2048).
These 2 Users Gave Thanks to Don Cragun For This Post:
Hi
I am having file :
1|2443094 |FUNG SIU TO |CLEMENT
2|2443095 |FUNG KIL FO |REMENT
This file contains only 3 fields delimeted by "|". Last field is a decsription filed and it contains character "|". Due to this my output if breaking in 4 fields. I... (7 Replies)
logs:
"/home/abc/public_html/index.php"
"/home/abc/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
"/home/xyz/public_html/index.php"
how to use "cut" or "awk" or "sed" to get the following result:
abc
abc
xyz
xyz
xyz (8 Replies)
Hello everyone
Sorry I have to add another sed question. I am searching a log file and need only the first 2 occurances of text which comes after (note the space) "string " and before a ",". I have tried
sed -n 's/.*string \(*\),.*/\1/p' filewith some, but limited success. This gives out all... (10 Replies)
Good afternoon all,
I'm hoping my newbie question can help bolster someone's street_cred.sh today.
I'm trying to "fingerprint" SQL on its way into the rdbms for a benchmarking process (so I can tie the resource allocation back to the process more precisely).
To do this, I'm essentially... (4 Replies)
Hi,
My input has much more lines, but few of them are below
pin(IDF) {
direction : input;
drc_pinsigtype : signal;
pin(SELDIV6) {
direction : input;
drc_pinsigtype : ... (3 Replies)
Hi All,
I'm trying to write a ksh script to parse a file. When the "\" character is encountered, it should be removed and the next line should be concatenated with the current line. For example...
this is a test
line #1\
should be concatenated with line #2\
and line number 3
when this... (3 Replies)