![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
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! |
|
||||
|
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. |
|
||||
|
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/\#.\*//" ) |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|