The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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
Asterisk on IPCop Asterisk 1.4.20 for IPCop 1.4.18 (Default branch) iBot Software Releases - RSS News 0 05-21-2008 08:40 PM
Asterisk on IPCop Asterisk 1.4.19.2 for IPCop 1.4.18 (Default branch) iBot Software Releases - RSS News 0 05-14-2008 07:20 AM
Asterisk on IPCop IPCop 1.4.18 with Asterisk 1.4.19.1 (Asterisk IPCop ISO branch) iBot Software Releases - RSS News 0 04-26-2008 04:10 AM
Asterisk on IPCop Asterisk 1.4.19.1 for IPCop 1.4.18 (Default branch) iBot Software Releases - RSS News 0 04-25-2008 04:10 PM
coping all files from a directory pavan_test UNIX for Dummies Questions & Answers 1 07-23-2006 04:35 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-06-2007
PaulUrwin PaulUrwin is offline
Registered User
  
 

Join Date: Sep 2007
Location: London, UK.
Posts: 1
Question For loop - coping with an asterisk item

How do you get a for loop to cope with one of the items being an asterisk?


for myResult in `echo "*"`
do
echo "$myResult"
done



The asterisk is returning a file listing in the PWD.

The same result can be got from:


for myResult in "*"
do
echo "$myResult"
done



How to I combat this?

Cheers.
  #2 (permalink)  
Old 09-07-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
Probably, you need to disable pathname expansion. Use set -f. Something like

Code:
(set -f; for file in `echo "*"`; do echo $file; done; )
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:35 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0