Help requested for a script with sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help requested for a script with sed
# 1  
Old 02-22-2009
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  
Old 02-23-2009
If you want help with sed, please post only the sed part and the input to sed and the expected or wanted output.
# 3  
Old 02-23-2009
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  
Old 02-23-2009
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/\#.\*//" )
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. IP Networking

The requested URL was rejected. Please consult with your administrator

Ggod evening. I need your help please, in a Production system there is a process that download a xls file from an URL which is IMF(International Monetary Fund) and afterwards to be loaded into a databse table. When testing conectivity from a unix server to IMF seems to work but when editing it... (9 Replies)
Discussion started by: alexcol
9 Replies

2. Shell Programming and Scripting

SQL Script HELP Requested.

Hello ALL , i am requesting help on for this script i am preparing to get the result of a query in a excel sheet : current Error: Script : NO Excel file created. requesting to know where i am going wrong. #!/bin/ksh... (2 Replies)
Discussion started by: anirudhkashikar
2 Replies

3. Forum Support Area for Unregistered Users & Account Problems

Sign in issues -- additional info as requested

User name: Michael Mullig <removed email addresses> (1 Reply)
Discussion started by: Mike Mullig
1 Replies

4. Shell Programming and Scripting

Help on sed requested

Hi I have a problem to resolve, I think sed is the best option, and I am not successful yet. Have a UNIX file which has records as of the 2 character state codes like NY NJ PA DE From the file I need to create this as a variable in the same script or another file -... (7 Replies)
Discussion started by: snair2010
7 Replies

5. Shell Programming and Scripting

Newbie bash scripting help requested

Hi, I'm very new to bash scripting and Linux in general. I'm running Ubuntu Server 10.04 and trying to write a bash script to launch a program. In doing so, I've come across a couple of things that I obviously don't understand. Here is a short script that exemplifies those things: ... (9 Replies)
Discussion started by: Carson Dyle
9 Replies

6. UNIX for Advanced & Expert Users

assistance requested (sed related)

I gotta write a command to change the accounts in /etc/passwd that use a shell other than the bash to bash shell. those accounts that dont use a shell shouldnt get modified. assuming all the shell programs end in sh and other programs dont. and the result should go into /etc/passwd.rev any hint? (4 Replies)
Discussion started by: metalwarrior
4 Replies

7. Shell Programming and Scripting

AWK issue--> Help requested

Fairly new scripter so please bare with me if what I have done below is not according to standards. Okay...heres what I am trying to do. I have a pattern that I need to search for in a directory. This gives me a list of files that includes a control file that contains totals of the line nos for... (3 Replies)
Discussion started by: alfredo123
3 Replies

8. AIX

AIX 4.1.5/RS6000 boot hang, help requested

Hello there! I have a RS-6000 7043-140 machine with AIX version 4.1.5, that is working for almost 8 years now. It has a tty monitor. My problem started when I upgraded my machine to install a gxt250 graphics adapter card together with a 15" AOC VGA Monitor, logitech keyboard and mouse, ... (2 Replies)
Discussion started by: bright_genius
2 Replies

9. Solaris

Your Opinion requested

Ladies/Gentlemen, I am looking for a web-based tool to keep track of my Sun inventory. The following list of fields are fields I would like to store: Root Passwd (needs to be secure) / Hostid / Console Port / IP Address / Platform / Application / Hostname . . . you get the point. Do any of... (4 Replies)
Discussion started by: pc9456
4 Replies

10. Email Antispam Techniques and Email Filtering

help requested: procmail receipes

Hello all. I want some help procmail receipe. I tried to get some mails' sender and receiptient. Then tried to send them a bash script. But it didnot work. I try a lot of variation of the below receipe. Could anyone can help what is wrong on my receipe? Or if the recepie is correct what can be... (0 Replies)
Discussion started by: kedi
0 Replies
Login or Register to Ask a Question