Sed label question

Hi,

I'm trying to run the below sed command someone showed me to remove comments, blank lines and line continuations from a file but I get the following label error: Label too long: :loop;/\\$/N;s/\\\n//;t loop

sed '/^ *#/d' <$1 | sed '/^$/d' | sed ':loop;/\\$/N;s/\\\n//;t loop' | sed 's/[ \t]\+/ /g' > $workfile

From what I can figure out its due to the label length only being allowed to have 8 characters.

Is there another way to write the above sed command so that I don't get a label error?

Thanks,
Jaz

change to

-e ':loop' -e '/\\$/N' -e 's/\\\n//;t loop'

or

-e ':loop' -e ';/\\$/N;s/\\\n//;t loop'

solaris sed wants to labels as separate expression..

Thanks for the reply ygemici..

Guess I'm going to have to test the sed bit by bit.. The whole command is just giving me a blank output.. In fact just even trying to remove lines with comments gives me a blank output..

sed '/^ *#/d' <$filename > $workfile

**EDIT**
Eventually got this working but now have an awk related question..

Anyone know if there's an -v alternative for Solaris? Doesn't seem to be supported in my version..

By the way its SunOS 5.10

what command you tried?
why do you search the alternative?

Hi ygemici,

I'm trying to run the below awk command but I'm getting the following... -v: not found

echo " *** split out comma separated 'commands' into separate rows *** "
awk -F| -v OFS='\t' '
{n=split($3,a,/,/)
 for(i=1;i<=n;i++){
   $3=a
   print  
 }
}' <${workfile}_2 | sort > ${workfile}_3

I'm thinking nawk might be whats needed instead but I can't figure out what the nawk command should be.. The man pages aren't that user friendly...

You need to escape the pipe character in the -F option because it is a Shell special character. If this is SunOS, most posters advise not using awk and choosing one of the alternatives instead.

Should I open a new thread or continue with this one? This all part of one script but they are different issues...

try this

# awk 'BEGIN{FS="|";OFS="\t "}{n=split($3,a,",");
for(i=1;i<=n;i++){$3=a;print}
}' <${workfile}_2 | sort > ${workfile}_3

and you can use nawk (or /usr/xpg4/bin/awk) instead of awk in solaris..

regards
ygemici