Gossamer Forum
Home : General : Internet Technologies :

I need help with shell script

Quote Reply
I need help with shell script
Hey all,

I am new to shell scripting and wondering if anyone could help me with my problem.
$ cat text.txt
TYPE 1A,BLUE,RED
TYPE 2B,ORANGE,YELLOW
TYPE 10AB,BLACK,GOLD
TYPE 11BC,GREEN,WHITE

my output should come out to:

TYPE 1,A,BLUE,RED
TYPE 2,B,ORANGE,YELLOW
TYPE 10,AB,BLACK,GOLD
TYPE 11,BC,GREEN,WHITE

Basically, I want to add a "," after the number.

Any input will be greatly appreciated.

Thanks,
Narsman
Quote Reply
Re: [narsman] I need help with shell script In reply to
Code:
gossamer root # perl -ple 's/(TYPE \d+)/$1,/' < test.txt
TYPE 1,A,BLUE,RED
TYPE 2,B,ORANGE,YELLOW
TYPE 10,AB,BLACK,GOLD
TYPE 11,BC,GREEN,WHITE
gossamer root #

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] I need help with shell script In reply to
Thanks, Alex. It worked! I'm not familiar with Perl, do you know the syntax using awk or bourne/c shell script?