Re: howto join lines

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2008-10-02 at 09:37 +1000, Norman Gaywood wrote:
> On Wed, Oct 01, 2008 at 03:55:08PM -0400, Chris Tyler wrote:
> > On Wed, 2008-10-01 at 14:40 -0500, Les Mikesell wrote:
> > > Patrick O'Callaghan wrote:
> > > >
> > > >>>> i want to have those lines joined to one line with
> > > >>> spaces
> > > >>>> Before :
> > > >>>>
> > > >>>> textone
> > > >>>> texttwo
> > > >>>> something
> > > >>>>
> > > >>>> After :
> > > >>>>
> > > >>>> textone texttwo something
> > > >>>>
> > > 
> > > echo `cat multi_line_file`
> > > or
> > > echo $(cat multi_line_file`)
> > 
> > Or to avoid the fork & exec:
> > 
> >     echo $(<multi_line_file)
> 
> But you will end up with problems with the number of arguments on a
> command line if multi_line_file is too large.
> 
> How about:
> 
> cat multi_line_file | xargs
> 
> Note that the default command for xargs is echo
> 
> Or, to avoid a "useless use of cat" award (see
> http://partmaps.org/era/unix/award.html):
> 
> xargs < multi_line_file

Alas, that doesn't solve the problem with the excessive number/length of
arguments either, because xargs will execute the echo multiple times if
necessary to keep within the arg limits, potentially generating newlines
in the output.

...Which is why I like the translate I proposed earlier:

   tr "\012" " " <multi_line_file

--
Chris

-- 
fedora-list mailing list
fedora-list@xxxxxxxxxx
To unsubscribe: https://www.redhat.com/mailman/listinfo/fedora-list
Guidelines: http://fedoraproject.org/wiki/Communicate/MailingListGuidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux