how to merge linesReorder Multiple Line Blocks with SedReading a string till a key word and replacing from...

Basic power tool set for Home repair and simple projects

A Tale of Snake and Coffee

What is the context for Napoleon's quote "[the Austrians] did not know the value of five minutes"?

How to know whether to write accidentals as sharps or flats?

The last tree in the Universe

How many times to repeat an event with known probability before it has occurred a number of times

Can an opamp have its own voltage regulator?

Was the Lonely Mountain, where Smaug lived, a volcano?

Why is gun control associated with the socially liberal Democratic party?

Using roof rails to set up hammock

Can artificial satellite positions affect tides?

Are soroban (Japanese abacus) classes worth doing?

What is the difference between state-based effects and effects on the stack?

Are athletes' college degrees discounted by employers and graduate school admissions?

I sent an angry e-mail to my interviewers about a conflict at my home institution. Could this affect my application?

How could I create a situation in which a PC has to make a saving throw or be forced to pet a dog?

How did the European Union reach the figure of 3% as a maximum allowed deficit?

How can I detect if I'm in a subshell?

Background for black and white chart

Do legislators hold the right of legislative initiative?

Can Dive Down protect a creature against Pacifism?

For Saintsbury, which English novelists constituted the "great quartet of the mid-eighteenth century"?

How to address players struggling with simple controls?

How to search for Android apps without ads?



how to merge lines


Reorder Multiple Line Blocks with SedReading a string till a key word and replacing from there with another stringWhy awk says “syntax error” for the comma I placed between the two patterns?Bash - Perl Script variable insertionawk with regex for delimiterAwk script only works if i edit the text file manuallyCross-referencing each field from a line with a column in another fileReplace a pattern in File1 and replace it with corresponding matched pattern + column in File2Subsetting a variable by patternmodify between (only) 1st occurrence of patterns (inclusive of patterns) and keep processing






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















Contests of a file is as follows:



cat -n /tmp/my_file



 1  verify(abc) {
2 foo : bar;
3 sub1(aa) {
4 line1;
5 }
6 sub2 (bb) {
7 line1;
8 // this line is a comment and must be ignored
9 line2;
10 sub3 (cc) {
11 line1;
12 }
13 }
14 }
15
16 verify(efg) {
17 foo : bar;
18 sub1(aa) {
19 line1;
20 }
21 sub2 (bb) {
22 line1;
23 // this line is a comment and must be ignored
24 line2;
25 sub3 (cc) {
26 line1;
27 }
28 }
29 }


And I need to have its content converted into following format using awk or perl:



verify(abc) { foo : bar; sub1 (aa) { line1; } sub2 (bb) { line1; line2; sub3 (cc) { line1; } } }



verify(efg) { foo : bar; sub1 (aa) { line1; } sub2 (bb) { line1; line2; sub3 (cc) { line1; } } }



Many thanks in advance.










share|improve this question









New contributor



rumi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • An end of line in Unix is character n, so you just need to any (that is not alone on a line) with some preprocessing to remove any line starting with //. What did you try already?

    – Patrick Mevzek
    52 mins ago











  • Removing lines starting with // is not a problem; what algorithm should I use to ensure contents of each "verify()" routine is place on one line?

    – rumi
    34 mins ago


















0















Contests of a file is as follows:



cat -n /tmp/my_file



 1  verify(abc) {
2 foo : bar;
3 sub1(aa) {
4 line1;
5 }
6 sub2 (bb) {
7 line1;
8 // this line is a comment and must be ignored
9 line2;
10 sub3 (cc) {
11 line1;
12 }
13 }
14 }
15
16 verify(efg) {
17 foo : bar;
18 sub1(aa) {
19 line1;
20 }
21 sub2 (bb) {
22 line1;
23 // this line is a comment and must be ignored
24 line2;
25 sub3 (cc) {
26 line1;
27 }
28 }
29 }


And I need to have its content converted into following format using awk or perl:



verify(abc) { foo : bar; sub1 (aa) { line1; } sub2 (bb) { line1; line2; sub3 (cc) { line1; } } }



verify(efg) { foo : bar; sub1 (aa) { line1; } sub2 (bb) { line1; line2; sub3 (cc) { line1; } } }



Many thanks in advance.










share|improve this question









New contributor



rumi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • An end of line in Unix is character n, so you just need to any (that is not alone on a line) with some preprocessing to remove any line starting with //. What did you try already?

    – Patrick Mevzek
    52 mins ago











  • Removing lines starting with // is not a problem; what algorithm should I use to ensure contents of each "verify()" routine is place on one line?

    – rumi
    34 mins ago














0












0








0


1






Contests of a file is as follows:



cat -n /tmp/my_file



 1  verify(abc) {
2 foo : bar;
3 sub1(aa) {
4 line1;
5 }
6 sub2 (bb) {
7 line1;
8 // this line is a comment and must be ignored
9 line2;
10 sub3 (cc) {
11 line1;
12 }
13 }
14 }
15
16 verify(efg) {
17 foo : bar;
18 sub1(aa) {
19 line1;
20 }
21 sub2 (bb) {
22 line1;
23 // this line is a comment and must be ignored
24 line2;
25 sub3 (cc) {
26 line1;
27 }
28 }
29 }


And I need to have its content converted into following format using awk or perl:



verify(abc) { foo : bar; sub1 (aa) { line1; } sub2 (bb) { line1; line2; sub3 (cc) { line1; } } }



verify(efg) { foo : bar; sub1 (aa) { line1; } sub2 (bb) { line1; line2; sub3 (cc) { line1; } } }



Many thanks in advance.










share|improve this question









New contributor



rumi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











Contests of a file is as follows:



cat -n /tmp/my_file



 1  verify(abc) {
2 foo : bar;
3 sub1(aa) {
4 line1;
5 }
6 sub2 (bb) {
7 line1;
8 // this line is a comment and must be ignored
9 line2;
10 sub3 (cc) {
11 line1;
12 }
13 }
14 }
15
16 verify(efg) {
17 foo : bar;
18 sub1(aa) {
19 line1;
20 }
21 sub2 (bb) {
22 line1;
23 // this line is a comment and must be ignored
24 line2;
25 sub3 (cc) {
26 line1;
27 }
28 }
29 }


And I need to have its content converted into following format using awk or perl:



verify(abc) { foo : bar; sub1 (aa) { line1; } sub2 (bb) { line1; line2; sub3 (cc) { line1; } } }



verify(efg) { foo : bar; sub1 (aa) { line1; } sub2 (bb) { line1; line2; sub3 (cc) { line1; } } }



Many thanks in advance.







linux awk perl






share|improve this question









New contributor



rumi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question









New contributor



rumi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question








edited 1 hour ago







rumi













New contributor



rumi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 1 hour ago









rumirumi

12




12




New contributor



rumi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




rumi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.















  • An end of line in Unix is character n, so you just need to any (that is not alone on a line) with some preprocessing to remove any line starting with //. What did you try already?

    – Patrick Mevzek
    52 mins ago











  • Removing lines starting with // is not a problem; what algorithm should I use to ensure contents of each "verify()" routine is place on one line?

    – rumi
    34 mins ago



















  • An end of line in Unix is character n, so you just need to any (that is not alone on a line) with some preprocessing to remove any line starting with //. What did you try already?

    – Patrick Mevzek
    52 mins ago











  • Removing lines starting with // is not a problem; what algorithm should I use to ensure contents of each "verify()" routine is place on one line?

    – rumi
    34 mins ago

















An end of line in Unix is character n, so you just need to any (that is not alone on a line) with some preprocessing to remove any line starting with //. What did you try already?

– Patrick Mevzek
52 mins ago





An end of line in Unix is character n, so you just need to any (that is not alone on a line) with some preprocessing to remove any line starting with //. What did you try already?

– Patrick Mevzek
52 mins ago













Removing lines starting with // is not a problem; what algorithm should I use to ensure contents of each "verify()" routine is place on one line?

– rumi
34 mins ago





Removing lines starting with // is not a problem; what algorithm should I use to ensure contents of each "verify()" routine is place on one line?

– rumi
34 mins ago










0






active

oldest

votes












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






rumi is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f524795%2fhow-to-merge-lines%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes








rumi is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















rumi is a new contributor. Be nice, and check out our Code of Conduct.













rumi is a new contributor. Be nice, and check out our Code of Conduct.












rumi is a new contributor. Be nice, and check out our Code of Conduct.
















Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f524795%2fhow-to-merge-lines%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Hudson River Historic District Contents Geography History The district today Aesthetics Cultural...

The number designs the writing. Feandra Aversely Definition: The act of ingrafting a sprig or shoot of one...

How big is the pipe buffer?Turn off buffering in pipeIn what order do piped commands run?When would you use...