Sponsored Content
Top Forums Shell Programming and Scripting How can i join three lines into one in unix? Post 302359296 by protocomm on Tuesday 6th of October 2009 07:55:12 AM
Old 10-06-2009
try this...

Code:
awk '{if (NR%3) {ORS="";print " "$0} else {ORS="\n";print " "$0}}'
 file

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

join two lines together

Hi, I have a file with on one line a uid, and on the next line a date. I am trying to make the to into one line. Here's an example: koppx 20031125 kraan 20031119 sarox 20031107 And this is what i want it to be: koppx;20031125 kraan;20031119 sarox;20031107 I have been trying... (4 Replies)
Discussion started by: tine
4 Replies

2. UNIX for Dummies Questions & Answers

how to join lines

can anyone tell me as "how to join all lines in a file " using a shell script Actually i have many files in a directory and for each file i want to join all the lines using a shell scrip . Thanks in advance!!! (8 Replies)
Discussion started by: glamo_2312
8 Replies

3. Shell Programming and Scripting

join lines

input1 x x input2 y x x z join input1 input2>>output ouput x x (2 Replies)
Discussion started by: repinementer
2 Replies

4. Shell Programming and Scripting

Join the lines

Hi All, Currently, the output looks like this: hdisk0 queue_depth:3 hdisk1 queue_depth:3 hdisk2 queue_depth:1 hdisk3 queue_depth:1 I need to change the format to look like this: hdisk0 queue_depth:3 hdisk1 queue_depth:3 hdisk2 queue_depth:1 (8 Replies)
Discussion started by: Beginer0705
8 Replies

5. Shell Programming and Scripting

join 2 lines

hi all i have sample and i need script to do this /dev/xxx oracle test /dev/sap 9999 000 88 99 i need the out put like this /dev/xxx oracle test /dev/sap 9999 000 88 99 can any one provide me with an idea to solve this problem (8 Replies)
Discussion started by: maxim42
8 Replies

6. Shell Programming and Scripting

join two lines

I want to join this two lines but only when after him I have nothing or a comma Yes, I know Jonesy, and I'll give him about one more minute. this two lines must become Yes, I know Jonesy, and I'll give him about one more minute. thank you very much (11 Replies)
Discussion started by: thailand
11 Replies

7. Shell Programming and Scripting

join lines in file

I have a file like this: --------------------------------------------------------------- 26 00:04:48,440 --> 00:04:51,440 I don't know why he can't just do the Great Apache Flaming Arrow Act. 27 00:04:52,440 --> 00:04:54,839 Didn't you tell him to use the gopher snake? 28... (1 Reply)
Discussion started by: thailand
1 Replies

8. Shell Programming and Scripting

Help in unix script to join similar lines of input

Hi, I have been thinking of how to script this but i have no clue at all.. Could someone please help me out or give me some idea on this? I would like to group those lines with the same first variable in each line, joining the 2nd variables with commas. Let's say i have the following input. ... (3 Replies)
Discussion started by: rei125
3 Replies

9. UNIX for Dummies Questions & Answers

how to join all lines in afile in unix

Hi, I have a unix file which has many lines, i need to join all the lines to single line. Eg: myfile.txt contains: a 123 45fg try and i need the output as : a 123 45fg try Please help me on this. Thanks! (2 Replies)
Discussion started by: RP09
2 Replies

10. Shell Programming and Scripting

Join Lines

Hi how do I join files like below in script. Thanks, Ashan there are may line like this in the file. zone name DR_TMP_A_sev1_3eA vsan 200 pwwn 50:00:09:73:f0:16:35:08 pwwn c0:50:76:08:6e:dc:00:16 zone name DR_TMP_A_SVR2_3eA vsan 200 pwwn 50:00:09:73:f0:16:35:08 pwwn... (4 Replies)
Discussion started by: ashanabey
4 Replies
Perl6::Say(3pm) 					User Contributed Perl Documentation					   Perl6::Say(3pm)

NAME
Perl6::Say - "print" -- but no newline needed SYNOPSIS
# Perl 5 code... use Perl6::Say; say 'boo'; # same as: print 'boo', " " say STDERR 'boo'; # same as: print STDERR 'boo', " " STDERR->say('boo'); # same as: print STDERR 'boo', " $fh->say('boo'); # same as: print $fh 'boo', " "; say(); # same as: print "$_ "; say undef; # same as: print " "; DESCRIPTION
Note for Users of Perl 5.10 You don't need this module. The Perl 6 "say" function is available in Perl 5.10 by saying "use feature 'say';". Hence, this module is of interest only to users of Perl 5.6 and 5.8. If you have Perl 5.10 installed, see the 510/ directory in this distribution for some elementary examples of "say" taken from "perldoc fea- ture". General Implements a close simulation of the "say" function in Perl 6, which acts like "print" but automatically appends a newline. Use it just like "print" (except that it only supports the indirect object syntax when the stream is a bareword). That is, assuming the relevant filehandles are open for output, you can use any of these: say @data; say FH @data; FH->say(@data); *FH->say(@data); (*FH)->say(@data); say $fh, @data; $fh->say(@data); but not any of these: say {FH} @data; say {*FH} @data; say {*FH} @data; say $fh @data; say {$fh} @data; Additional Permitted Usages As demonstrated in the test suite accompanying this distribution, "Perl6::Say::say()" can be used in all the following situations. $string = q{}; open FH, ">", $string; say FH qq{Hello World}; # print to a string close FH; # requires Perl 5.8.0 or later use FileHandle; $fh = FileHandle->new($file, 'w'); if (defined $fh) { say $fh, qq{Hello World}; $fh->close; } use IO::File; $fh = IO::File->new($file, 'w'); if (defined $fh) { say $fh, qq{Hello World}; $fh->close; } $string = q{}; open FH, ">", $string; # requires Perl 5.8.0 or later select(FH); say qq{Hello World}; close FH; Interaction with Output Record Separator In Perl 6, "say @stuff" is exactly equivalent to "Core::print @stuff, " "". That means that a call to "say" appends any output record separator (ORS) after the added newline (though in Perl 6, the ORS is an attribute of the filehandle being used, rather than a global $/ variable). "IO::Handle::say()" IO::Handle version 1.27 or later (which, confusingly, is found in IO distribution 1.23 and later) also implements a "say" method. Perl6::Say provides its own "say" method to IO::Handle if "IO::Handle::say" is not available. Usage with Older Perls As noted above, some aspects of "Perl6::Say::say()" will not work with versions of Perl earlier than 5.8.0. This is not due to any problem with this module; it is simply that Perl did not support printing to an in-memory file ("print $string, " ";") prior to that point. (Thanks to a CPAN testers report from David Cantrell for identifying this limitation.) WARNING
The syntax and semantics of Perl 6 is still being finalized and consequently is at any time subject to change. That means the same caveat applies to this module. DEPENDENCIES
No dependencies other than on modules included with the Perl core as of version 5.8.0. Some of the files in the test suite accompanying this distribution use non-core CPAN module IO::Capture::Stdout. Tests calling IO::Cap- ture::Stdout methods are enclosed in "SKIP" blocks and so should pose no obstacle to installation of the distribution on systems lacking IO::Capture. (However, the maintainer strongly recommends IO::Capture for developers who write a lot of test code. So please consider installing it!) AUTHOR and MAINTAINER AUTHOR Damian Conway (damian@conway.org). MAINTAINER James E Keenan (jkeenan@cpan.org) (effective v0.06, July 2006). ACKNOWLEDGMENTS
Thanks to Damian Conway for dreaming this up. Thanks to David A Golden for a close review of the documentation. Thanks to CPAN tester Jost Krieger for reporting an error in my SKIP block count in one test file. BUGS AND IRRITATIONS
As far as we can determine, Perl 5 doesn't allow us to create a subroutine that truly acts like "print". That is, one that can simultane- ously be used like so: say @data; and like so: say {$fh} @data; Comments, suggestions, and patches welcome. COPYRIGHT
Copyright (c) 2004, Damian Conway. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. perl v5.8.8 2008-02-09 Perl6::Say(3pm)
All times are GMT -4. The time now is 10:50 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy