SPUG: perl one-liner help
Chris Wilkes
cwilkes-spug at ladro.com
Wed Apr 4 15:15:20 PDT 2007
On Wed, Apr 04, 2007 at 03:08:47PM -0700, Duane Blanchard wrote:
>
> I have a list of names in a file separated by a semicolon and a space:
>
> Starr, Ringo; McCartney, Paul; Lennon, John; Harrison, George;
>
> and I want to substitute each /; / with a /\n/.
>
> I'm running WinXP.
>
> perl -e "s/; /\n/" desktop/list.txt
You're close:
perldoc perlrun
shows that you're looking for the -p switch:
perl -pe "s/; /\n/g" desktop/list.txt
throw in a "/g" in your regexp to say that you want to repeat the
match on the same line.
Chris
More information about the spug-list
mailing list