The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
assistance requested (sed related) metalwarrior UNIX for Advanced & Expert Users 4 02-05-2008 02:44 AM
AWK issue--> Help requested alfredo123 Shell Programming and Scripting 3 02-27-2007 04:08 PM
AIX 4.1.5/RS6000 boot hang, help requested bright_genius AIX 2 01-31-2006 10:59 PM
Your Opinion requested pc9456 SUN Solaris 4 11-17-2003 09:56 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-22-2009
fatimap fatimap is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 2
Help requested for a script with sed

Hello Folks,
I would very much appreciate if I could get help/suggestions on a particular sed usage. I have to write a script to take version info from a version file, compute the image name, print error if the image does not exist.
The version file looks like below:

"
Code:
#
# version.cfg
#
version =   4.2.1.1.10  # 
"

The script seems to get the image name right but does not expand correctly in "ifeq ($(wildcard $(IMAGE_FILE)), )"

This is what I get:
"
IMAGE_FILE = ./images/release-4.2.1.1.10.tar.gz 
Makefile:19: *** No image file "./images"/release-`grep version ./version.cfg | grep "=" | cut -d'=' -f2 | sed -e 's/#.*//' -e 's/[ ^   ]*//' -e 's/\ .*//'`.tar.gz.  Stop.
"

This is my script:
==================
"
.PHONY: chkImage
VERSION_FILE := ./version.cfg
ifeq ($(wildcard $(VERSION_FILE)),)
    $(error $(nl-ht)No Version File $(VERSION_FILE) Exists) 
endif
ImageRoot := "./images"
Version := `grep version $(VERSION_FILE) | grep "=" | cut -d'=' -f2 |   \
                    sed -e 's/\#.*//' -e 's/[ ^ ]*//' -e 's/\ .*//'`
Image := release-$(Version).tar.gz
IMAGE_FILE := $(ImageRoot)/$(Image)

all: chkImage

chkImage:
        @printf "IMAGE_FILE = $(IMAGE_FILE) \n"
ifeq ($(wildcard $(IMAGE_FILE)), )
    $(error $(nl-ht)No image file $(IMAGE_FILE))
endif
"

Your help in resolving this issue would be greatly appreciated.

Last edited by Neo; 02-23-2009 at 12:41 PM.. Reason: Added code tags - please use them!
  #2 (permalink)  
Old 02-23-2009
Neo's Avatar
Neo Neo is offline Forum Staff  
Administrator
  
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 6,832
If you want help with sed, please post only the sed part and the input to sed and the expected or wanted output.
  #3 (permalink)  
Old 02-23-2009
fatimap fatimap is offline
Registered User
  
 

Join Date: Feb 2009
Posts: 2
variable expansion does not happen some times

Version := `grep version $(VERSION_FILE) | grep "=" | cut -d'=' -f2 | \
sed -e 's/\#.*//' -e 's/[ ^ ]*//' -e 's/\ .*//'`
Image := release-$(Version).tar.gz
IMAGE_FILE := $(ImageRoot)/$(Image)

The variable IMAGE_FILE does not seem to expand when I do:

$(error No image file $(IMAGE_FILE))

I get:
"No image file "./images"/release-`grep version ./version.cfg | grep "=" | cut -d'=' -f2 | sed -e 's/#.*//' -e 's/[ ^ ]*//' -e 's/\ .*//'`.tar.gz"

What should I do to effect immediate expansion?

Thanks.
  #4 (permalink)  
Old 02-23-2009
curleb curleb is offline
Registered User
  
 

Join Date: Mar 2008
Location: Here, in my Ivory Tower...
Posts: 68
wouldn't your use of single-quotes make them literal strings?

try to use double-quotes around your sed -e scripts and be sure to escape accordingly for other reg expresssion chars, such as asterisk (ie, sed -e "s/\#.\*//" )
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 07:24 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0