Re: Regex for white space
From: Lew Pitcher (Lew.Pitcher_at_td.com)
Date: 11/23/05
- Next message: Stephane CHAZELAS: "Re: bullet proof for loop over $(find) in bash, how?"
- Previous message: Chris F.A. Johnson: "Re: Replacing embedded ^M with UNIX newline char"
- In reply to: Ying Zu: "Regex for white space"
- Next in thread: johngnub: "Re: Regex for white space"
- Reply: johngnub: "Re: Regex for white space"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 23 Nov 2005 14:48:15 -0500
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Ying Zu wrote:
> Suppose a series of white spaces in between a string, just like"
>
> "foo fooo foooo fooooo"
>
> Now I wonder how can I get a new string contains no spaces or substuted by symbols like _
tr(1) or sed(1) should do
pitchl@srdscs05:~$ echo "foo fooo foooo fooooo" | tr '[:blank:]' '_'
foo_fooo_foooo__fooooo
pitchl@srdscs05:~$ echo "foo fooo foooo fooooo" | tr -d '[:blank:]'
foofooofoooofooooo
pitchl@srdscs05:~$ echo "foo fooo foooo fooooo" \
| sed 's/[[:blank:]]/_/g'
foo_fooo_foooo__fooooo
pitchl@srdscs05:~$ echo "foo fooo foooo fooooo" \
| sed 's/[[:blank:]]//g'
foofooofoooofooooo
> Maybe a simple regex use but I am a newbie in shell script...
>
> thanks :)
- --
Lew Pitcher, IT Specialist, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group
(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)
iD8DBQFDhMd+agVFX4UWr64RApb1AKCTiSzvVRgLB4T414bfNUpJNg7IcQCfZQju
w4MiH/PxbomL5Z46WePz0y8=
=iblw
-----END PGP SIGNATURE-----
- Next message: Stephane CHAZELAS: "Re: bullet proof for loop over $(find) in bash, how?"
- Previous message: Chris F.A. Johnson: "Re: Replacing embedded ^M with UNIX newline char"
- In reply to: Ying Zu: "Regex for white space"
- Next in thread: johngnub: "Re: Regex for white space"
- Reply: johngnub: "Re: Regex for white space"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|