LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-21-2004, 08:54 PM   #1
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
How do you set a shell script var with a literal '*'?


I'm trying to do something like this:

Code:
#!/bin/tcsh

set EXCLUDE = "\\\*.cmv"

foreach f (`eval "ls /job"`)
    eval "tar --exclude=big_files --exclude=$EXCLUDE -cvzf $f.tgz $f"
end
if I do an env var like so:
setenv FOO \\\*.c

I can check it and it seems to work:
setenv | grep FOO
FOO=\*.c

but, if I echo $FOO:
echo $FOO
echo: No match.



the tar command above is still getting .cmv files, so it's not working like I'd like

ideas?

Last edited by BrianK; 06-21-2004 at 08:57 PM.
 
Old 06-21-2004, 09:02 PM   #2
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
edited:

ok, so I got one var working properly, but I can't get an array - i.e.:

Code:
#!/bin/tcsh

set IGNORE = ( drqueue \
	       non_jobs \
	       makeQuicktime )

set EXCLUDE = ( big_files \
	        \\\*.cmv \
	        core.\\\* )

set IGNORE_STRING = "ls "
set EXCLUDE_STRING = ""

foreach ig ($IGNORE)
    set IGNORE_STRING = "${IGNORE_STRING} | grep -v $ig"
end

foreach ex ($EXCLUDE)
    set EXCLUDE_STRING = "${EXCLUDE_STRING} --exclude=$ex"
end

foreach f (`eval $IGNORE_STRING`)
    eval "tar $EXCLUDE_STRING -cvzf $f.tgz $f"
end
this doesn't work... I get:
foreach: No match. (refering the the foreach ex ($EXCLUDE))

??

Last edited by BrianK; 06-21-2004 at 09:15 PM.
 
Old 06-22-2004, 01:35 PM   #3
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
have you tried foreach ig (${IGNORE}) ?
 
Old 06-22-2004, 02:11 PM   #4
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Original Poster
Rep: Reputation: 51
Quote:
Originally posted by keefaz
have you tried foreach ig (${IGNORE}) ?
I had not, but that still does not work.

And, for the record, the $IGNORE foreach works fine, it's the $EXCLUDE foreach that's having problems.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
Need shell script to set passwords for already created users naren_0101bits Programming 2 08-28-2005 02:02 PM
can I set these flags using a shell script nirav.jani Linux - Security 1 01-12-2005 06:01 PM
bash shell env var script ejbest Linux - Newbie 4 09-29-2004 10:23 AM
is it safe to set /var to chmod 777 carlosruiz Linux - Security 4 12-31-2003 04:00 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration