Advertisement

01.06.2008 at 11:41PM PST, ID: 23062937
[x]
Attachment Details

Substitutions  in csh script

Asked by Jerryleo in csh / tcsh, Programming Languages, Shell Scripting

Tags: Csh, Fedora core 3

I'm using csh on fc3.  I'd like to use find command and exclude some files under specified directory. I put the exclude files list in a text file, and read it from a csh script to combine the find options on the fly.  I failed to get it work,  it always complains " find: No match. ".  I know it is a substitutions issue,  but I don't know how to do it in the right way. Can someone tell me how should I do?

Thanks  a lot!

JerryStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
set Exclude_List=ex_files.txt
  set FIND_OPT="-type f"
  set EXCLUDE="-iname `head -n 1 ${Exclude_List} | sed 's/\*/\\\*/' | sed 's/\?/\\\?/'`"
  foreach f (`tail -n +2 ${Exclude_List} | sed 's/\*/\\\*/' | sed 's/\?/\\\?/'`)
    set EXCLUDE='${EXCLUDE} -o -iname $f'
  end
  set FIND_OPT="${FIND_OPT} ! \( ${EXCLUDE} \)"
endif
  set FILE_LIST=/tmp/tmp_$$
  pushd $WORKDIR
  find ./ ${FIND_OPT} -printf "%f\n"  > $FILE_LIST
  pop
 
 
****** ex_files.txt example*********
*.log
*.tmp
auto????.list
***********end of example **********
[+][-]01.07.2008 at 12:21AM PST, ID: 20597638

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.07.2008 at 12:32AM PST, ID: 20597661

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.07.2008 at 12:47AM PST, ID: 20597692

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01.07.2008 at 02:10AM PST, ID: 20597997

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.07.2008 at 02:21AM PST, ID: 20598040

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01.07.2008 at 02:39AM PST, ID: 20598107

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: csh / tcsh, Programming Languages, Shell Scripting
Tags: Csh, Fedora core 3
Sign Up Now!
Solution Provided By: ozo
Participating Experts: 2
Solution Grade: B
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628