Re: howto join lines

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

 



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
 
-- 
Norman Gaywood, Computer Systems Officer
University of New England, Armidale, NSW 2351, Australia

ngaywood@xxxxxxxxxx            Phone: +61 (0)2 6773 3337
http://mcs.une.edu.au/~norm    Fax:   +61 (0)2 6773 3312

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html

-- 
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]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux