Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Appending trailing commas! 1

Status
Not open for further replies.
Sep 22, 2004
27
0
0
US
HI gurus!
I have a input file as follows:
nvl(BIN_NBR, ' ') ,
ACTN_CD ,
nvl(NBR, ' ') ,
DC_ACTN_CD ,
SORT_ID ,
ID_ACTN_CD ,
S_ID ,
CN_ID ,
ASD_CNT ,
nvl(COFG_CD, 0) ,
SPRINT_CD_ACTN_CD ,
my desired output is :
nvl(BIN_NBR, ' '),
ACTN_CD,
nvl(NBR, ' '),
DC_ACTN_CD,
SORT_ID,
ID_ACTN_CD,
S_ID,
CN_ID,
ASD_CNT,
nvl(COFG_CD, 0),
SPRINT_CD_ACTN_CD,

That is the comma (,) should be appended at the end of each statement whereas in the original input i have spaces between the two.
Please advice on how to achieve this.
Thanks
Roe
 
oops. sorry:

awk '{printf(%s%s,$1,$2)}' the_file.txt > result_file.txt
 
aahhh

awk '{ printf("%s%s",$1,$2) }' the_file.txt > result_file.txt
 
Hi chacalinc,
The awk concatenates all the lines and doesnt restore the spaces between.
say Select actb_cd pair() ,
actv_df_pair ,
is converted to Selectactb_cd pair(),actv_df_pair,

Thanks
roe
 
sed -e 's/[ ]*,$/,/g' file.txt

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top