Typecasting problem??

 echo $verbiage
"Nigeria","Can Nigeria succeed in their quest for a top 4 finish? Get daily Nigeria news, GOALS and LIVE Match updates for 30days at N200.Click Accept to SUBSCRIBE"

[/CODE]

but when i run this command

sed 's/$/",$verbiage"/g' noverb.F5

[/CODE]

I get below o/p

",$verbiage"0,s2ZsUMmoMCdllhIdZSWxdBl7cH0=,S40,1.6.52,MTN
",$verbiage"4,s2ZsUMmoMCdllhIdZSWxdBl7cH0=,S40,1.6.52,MTN
",$verbiage"2,pSSDGuUiPRX5c2MQUaBKYjvzOwg=,S30,4.0,MTN

[/CODE]

file content is

23470330,s2ZsUMmoMCdllhIdZSWxdBl7cH0=,S40,1.6.52,MTN
2398774,s2ZsUMmoMCdllhIdZSWxdBl7cH0=,S40,1.6.52,MTN
2379162,pSSDGuUiPRX5c2MQUaBKYjvzOwg=,S30,4.0,MTN

[/CODE]

required o/p is

23484374,s2ZsUMmoMCdllhIdZSWxdBl7cH0=,S40,1.6.52,MTN,"Nigeria","Can Nigeria succeed in their quest for a top 4 finish? Get daily Nigeria news, GOALS and LIVE Match updates for 30days at N200.Click Accept to SUBSCRIBE"
23480162,pSSDGuUiPRX5c2MQUaBKYjvzOwg=,S30,4.0,MTN,"Nigeria","Can Nigeria succeed in their quest for a top 4 finish? Get daily Nigeria news, GOALS and LIVE Match updates for 30days at N200.Click Accept to SUBSCRIBE"

[/CODE]

Try this

sed -i "s/\$/ ,$verbiage/" noverb.F5

Hi vikram

I tried ur command, but it aint working, its just givin me the o/p of verbiage

 , "Nigeria","Can Nigeria succeed in their quest for a top 4 finish? Get daily Nigeria news, GOALS and LIVE Match updates for 30days at N200.Click Accept to SUBSCRIBE"
 , "Nigeria","Can Nigeria succeed in their quest for a top 4 finish? Get daily Nigeria news, GOALS and LIVE Match updates for 30days at N200.Click Accept to SUBSCRIBE"
 , "Nigeria","Can Nigeria succeed in their quest for a top 4 finish? Get daily Nigeria news, GOALS and LIVE Match updates for 30days at N200.Click Accept to SUBSCRIBE"

[/CODE]

cat vikram13.sh
23470330,s2ZsUMmoMCdllhIdZSWxdBl7cH0=,S40,1.6.52,MTN
2398774,s2ZsUMmoMCdllhIdZSWxdBl7cH0=,S40,1.6.52,MTN
2379162,pSSDGuUiPRX5c2MQUaBKYjvzOwg=,S30,4.0,MTN
vi vikram14.sh
#!/bin/sh
verbiage=('"Nigeria","Can Nigeria succeed in their quest for a top 4 finish? Get daily Nigeria news, GOALS and LIVE Match updates for 30days at N200.Click Accept to SUBSCRIBE"')
echo $verbiage
sed -i "s/\$/, $verbiage/" vikram13.sh

After running the script

vikram14.sh
cat vikram13.sh
23470330,s2ZsUMmoMCdllhIdZSWxdBl7cH0=,S40,1.6.52,MTN, "Nigeria","Can Nigeria succeed in their quest for a top 4 finish? Get daily Nigeria news, GOALS and LIVE Match updates for 30days at N200.Click Accept to SUBSCRIBE"
2398774,s2ZsUMmoMCdllhIdZSWxdBl7cH0=,S40,1.6.52,MTN, "Nigeria","Can Nigeria succeed in their quest for a top 4 finish? Get daily Nigeria news, GOALS and LIVE Match updates for 30days at N200.Click Accept to SUBSCRIBE"
2379162,pSSDGuUiPRX5c2MQUaBKYjvzOwg=,S30,4.0,MTN, "Nigeria","Can Nigeria succeed in their quest for a top 4 finish? Get daily Nigeria news, GOALS and LIVE Match updates for 30days at N200.Click Accept to SUBSCRIBE"

Vikram

when i'm running inside the script m gettin the same o/p as mentiond previously

while read line
do
batch=`echo $line|awk -F"|" '{print $1}'`
echo "$line"|awk -F"|" '{print $2}'>verbiage_file.$batch
grep $batch icm_sample.csv > toberun.csv.$batch
sed "s/:/,/g" verbiage_file.$batch>org_verbiage.$batch
verbiage=`cat org_verbiage.$batch`
#awk -F"," '{print $2","$3","$4","$5","$6}' toberun.csv.$batch > noverb.$batch
#sed "s/$/,$verbiage/g" noverb.$batch > actual.$batch
sed -i "s/\$/, $verbiage/" toberun.csv.$batch
#paste actual.$batch org_verbiage.$batch > file_running.$batch
done < test
~

[/CODE]

I'd bet your file has windows control chars in it, at least a <CR> at the end. Get rid of those and it will fly.
And, in the regex, you don't need the \ in front of the $ sign representing the line end...

1 Like

Hello Rudic,

Thanks for correcting me.

\

not required in front of

$

in regex . :slight_smile: