Sed label question


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Sed label question
# 1  
Old 06-07-2012
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

Code:
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

Last edited by Jazmania; 06-07-2012 at 11:24 AM..
# 2  
Old 06-07-2012
change to
Code:
-e ':loop' -e '/\\$/N' -e 's/\\\n//;t loop'

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

solaris sed wants to labels as separate expression..
# 3  
Old 06-07-2012
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..

Code:
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

Last edited by Jazmania; 06-07-2012 at 02:29 PM..
# 4  
Old 06-07-2012
Quote:
Originally Posted by Jazmania
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..

Code:
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?
# 5  
Old 06-08-2012
Hi ygemici,


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

Code:
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[i]
   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...


Quote:
User Commands awk(1)

NAME
awk - pattern scanning and processing language

SYNOPSIS
/usr/bin/awk [-f progfile] [-Fc] [ ' prog '] [parameters]
[filename...]

/usr/xpg4/bin/awk [-FcERE] [-v assignment...] 'program'
-f progfile... [argument...]

DESCRIPTION
The /usr/xpg4/bin/awk utility is described on the nawk(1)
manual page.
Moderator's Comments:
Mod Comment edit by bakunin: you should open separate threads for separate problems. It is OK to ask follow-up questions, but the two problems presented by you here are not really connected in any way other than being both your problems, are they?

Last edited by bakunin; 06-08-2012 at 07:17 AM..
# 6  
Old 06-08-2012
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.
# 7  
Old 06-08-2012
Quote:
Moderator's Comments:
Mod Comment edit by bakunin: you should open separate threads for separate problems. It is OK to ask follow-up questions, but the two problems presented by you here are not really connected in any way other than being both your problems, are they?
Should I open a new thread or continue with this one? This all part of one script but they are different issues...

Last edited by methyl; 06-08-2012 at 11:59 AM.. Reason: fix tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. AIX

Which IP label is used for HeartBeating?

Hi, In HACMP, which IP label ( Service/ Boot/ Persisten) is used for send/receive Heartbeat packets in IP based Heartbeating? (1 Reply)
Discussion started by: ksgnathan
1 Replies

2. Shell Programming and Scripting

For loop using LABEL

Hi, i have below code so i want to run only one for loop instead of two. if ; then FILE_NAME_SLS=`cat $FILE_PATH|grep 'GTDA_Dly_Sls_'` DELMT="|" for i in $FILE_NAME_SLS do ABaC_COL_SL=`cut -d "$DELMT"... (6 Replies)
Discussion started by: renuk
6 Replies

3. Solaris

Help:"Bad checksum in disk label" and "Can't open disk label package"?

Hello, I'm brand new to Sun/Solaris. I have a Sun Blade 150, with SunOS 5.8. I wanted to make a backup to prevent future data loss, so I put the disk in a normal PC with Windows XP to try to make a backup with Norton Ghost, the disk was detected, but not the file volume, so I place the disk... (6 Replies)
Discussion started by: Resadija
6 Replies

4. Shell Programming and Scripting

Using A Goto Label?

Im trying to do something like this but I cant find any documentation. read X if then goto ThisLine fi OTHER CODE OTHER CODE Label: ThisLine echo "You entered 1" (5 Replies)
Discussion started by: Grizzly
5 Replies

5. BSD

FreeBSD Label Editor Post-install Question

Hello there, Over the past few days I have installed FreeBSD 7.1 (which i'm new at) to an external Hard Drive. When installing, I chose to partition the disk Automatically and now I'm trying to use the label editor (post-installation configuration) to name the mount points: / /usr... (2 Replies)
Discussion started by: septima.pars
2 Replies

6. Shell Programming and Scripting

Sed Question 1. (Don't quite know how to use sed! Thanks)

Write a sed script to extract the year, rank, and stock for the most recent 10 years available in the file top10_mktval.csv, and output in the following format: ------------------------------ YEAR |RANK| STOCK ------------------------------ 2007 | 1 | Exxon... (1 Reply)
Discussion started by: beibeiatNY
1 Replies

7. AIX

Label: Fcp_array_err4

In errpt i have got the following error and my database performs slow. --------------------------------------------------------------------------- LABEL: FCP_ARRAY_ERR4 IDENTIFIER: D5385D18 Date/Time: Tue Jul 22 10:50:10 CUT Sequence Number: 193913 Machine Id: ... (1 Reply)
Discussion started by: vjm
1 Replies

8. HP-UX

Label printing help

Hi I need some help in label printing with Zebra printers. (Model 220xiII) Here is a small test label file which prints fine in portrait format. Can anyone tell me how to change the label printing mode to landscape format? HEADER;TESTLBL;1;1;5;4... (0 Replies)
Discussion started by: rpalghat
0 Replies

9. AIX

Label: Disk_err4

I was trying to access my filesystem "tools" but couldn't, so I run fsck, but says Unable to read superblock (TERMINATED) when try mounting says mount: /dev/lv01 on /tools: I/O error the state of logical volumes of rootvg are "open/stale", what does it means? LV NAME TYPE ... (4 Replies)
Discussion started by: andwhat
4 Replies

10. AIX

Label:scan_error_chrp

Am getting an error in error log LABEL: SCAN_ERROR_CHRP IDENTIFIER: BFE4C025 Date/Time: Wed May 17 10:49:32 CUT Sequence Number: 6738 Machine Id: 00CD552E4C00 Node Id: dbs104 Class: H Type: PERM Resource Name: sysplanar0 Resource Class:... (0 Replies)
Discussion started by: vjm
0 Replies
Login or Register to Ask a Question