Unix/Linux Go Back    

Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

foreach in csh

Shell Programming and Scripting

Closed Linux or Unix Question    
Thread Tools Search this Thread Display Modes
Old Unix and Linux 02-03-2011
kristinu kristinu is offline
Registered User
Join Date: Dec 2009
Last Activity: 14 July 2015, 6:58 PM EDT
Posts: 869
Thanks: 64
Thanked 8 Times in 8 Posts
foreach in csh

I have a foreach loop in a csh script and I noticed that it tries to find the files with the pattern *$searchpt* in the file name. I'm confused as I never specified checking for the files.

    foreach f ( *$searchpt* )
      set fnew = `echo $f | awk -v searchpat=$searchpt    \
                                -v replacepat=$replacept  \
                                '{sub(searchpat,replacepat); print}'`

Sponsored Links
Old Unix and Linux 02-03-2011
DGPickett DGPickett is offline Forum Advisor  
Registered User
Join Date: Oct 2010
Last Activity: 4 November 2015, 3:30 PM EST
Location: Southern NJ, USA (Nord)
Posts: 4,671
Thanks: 8
Thanked 587 Times in 560 Posts
* says check for files, through shell globbing, unless you quote it.
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Using sed with a foreach loop Peggy White Shell Programming and Scripting 2 01-24-2009 09:37 AM
foreach statement in ksh asulli01 UNIX for Dummies Questions & Answers 8 11-26-2008 03:55 PM
foreach loop ROOZ Shell Programming and Scripting 3 06-05-2008 04:20 PM
using foreach loop sam4now Shell Programming and Scripting 6 04-26-2008 12:22 PM
foreach command ?! geoquest UNIX for Dummies Questions & Answers 5 05-20-2002 06:11 PM

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