From owner-freebsd-questions@FreeBSD.ORG Sun Mar 14 14:45:30 2004 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 70EF416A4CE for ; Sun, 14 Mar 2004 14:45:30 -0800 (PST) Received: from smtp.infracaninophile.co.uk (ns0.infracaninophile.co.uk [81.2.69.218]) by mx1.FreeBSD.org (Postfix) with ESMTP id 17A0A43D1F for ; Sun, 14 Mar 2004 14:45:29 -0800 (PST) (envelope-from m.seaman@infracaninophile.co.uk) Received: from happy-idiot-talk.infracaninophile.co.uk (localhost.infracaninophile.co.uk [IPv6:::1])i2EMjOo4019505 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 14 Mar 2004 22:45:24 GMT (envelope-from matthew@happy-idiot-talk.infracaninophile.co.uk) Received: (from matthew@localhost)id i2EMjN8K019504; Sun, 14 Mar 2004 22:45:23 GMT (envelope-from matthew) Date: Sun, 14 Mar 2004 22:45:23 +0000 From: Matthew Seaman To: "Steven N. Fettig" Message-ID: <20040314224523.GA19054@happy-idiot-talk.infracaninophile.co.uk> Mail-Followup-To: Matthew Seaman , "Steven N. Fettig" , freebsd-questions@freebsd.org References: <4054DD10.5060504@stevenfettig.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="gBBFr7Ir9EOA20Yy" Content-Disposition: inline In-Reply-To: <4054DD10.5060504@stevenfettig.com> User-Agent: Mutt/1.5.6i X-Spam-Status: No, hits=-4.8 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=2.63 X-Spam-Checker-Version: SpamAssassin 2.63 (2004-01-11) on happy-idiot-talk.infracaninophile.co.uk X-Virus-Scanned: clamd / ClamAV version devel-20040304, clamav-milter version 0.67j cc: freebsd-questions@freebsd.org Subject: Re: [OT] sed question X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Mar 2004 22:45:30 -0000 --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sun, Mar 14, 2004 at 04:30:40PM -0600, Steven N. Fettig wrote: > Sorry for posting an off-topic question to the list, but this is=20 > somethin that has been driving me nuts for weeks now and I can't figure= =20 > it out. I want to pass a text file through sed that replaces all=20 > whitespaces with a carriage return. I.e., if I have the file=20 > my_test_text_document.txt that is a few paragraphs of writing, I want to= =20 > take the following input: >=20 > I have just written five paragraphs of absolute jibberish and wish that= =20 > I could get sed to work the way that I want. Oh how this question has=20 > plagued me! >=20 > And have sed output: > I > have > just > written > five > paragraphs > of > absolute > jibberish > and > ... you get the point. >=20 > I can't figure out what the newline character is... I've tried \n \r &\,= =20 > etc. with no avail. I run the following: >=20 > sed 's/[ ]/\n/g' my_test_text_document.txt >=20 > and the output never has a newline added regardless of what I have=20 > substituted \n with. I have also used " instead of ' and that hasn't=20 > helped... > Sorry for the question, but I'd really appreciate the help! sed(1) can do it, but it's cleaner and simpler to use tr(1): % cat foo I have just written five paragraphs of absolute jibberish and wish that= =20 I could get sed to work the way that I want. Oh how this question has= =20 plagued me! % tr -s ' ' '\n' < foo I have just written five paragraphs of absolute jibberish and wish that I could get sed to work the way that I want. Oh how this question has plagued me! =20 Cheers, Matthew --=20 Dr Matthew J Seaman MA, D.Phil. 26 The Paddocks Savill Way PGP: http://www.infracaninophile.co.uk/pgpkey Marlow Tel: +44 1628 476614 Bucks., SL7 1TH UK --gBBFr7Ir9EOA20Yy Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFAVOCDdtESqEQa7a0RAmyPAJ91GZAvSiXhfeixz9BCfMctb5nIwACdHDz/ 3ZCgRNLJ5eELMKi49MAmb7w= =Cy/M -----END PGP SIGNATURE----- --gBBFr7Ir9EOA20Yy--