The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
removing the extension from all filenames in a folder johnmcclintock UNIX for Dummies Questions & Answers 5 05-21-2008 05:23 AM
bash: reading filenames from file warp17 Shell Programming and Scripting 0 03-04-2008 03:28 AM
reading long filenames from nero to AIX categoryzd UNIX for Dummies Questions & Answers 1 05-18-2006 07:57 AM
Adding an extension to a group of filenames pepintheshort UNIX for Dummies Questions & Answers 9 04-09-2004 05:11 PM
reading filenames inside a program j_t_kim UNIX for Dummies Questions & Answers 5 04-04-2002 11:13 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 01-21-2008
Registered User
 

Join Date: Jan 2008
Posts: 8
Reading filenames with extension .xml

Hi,

I want to write a script to read all the filenames with extension .xml in a directory and pass the name of the file, one by one, to another function.

Please help me out.

Regards.
Saurabh
Reply With Quote
Forum Sponsor
  #2  
Old 01-21-2008
Registered User
 

Join Date: May 2007
Posts: 104
Code:
for file in /path/to/*.xml
do
grep stuff $file
done
Reply With Quote
  #3  
Old 01-21-2008
awk awk is offline
Registered User
 

Join Date: Feb 2007
Posts: 120
Quote:
Originally Posted by bhalotias View Post
Hi,

I want to write a script to read all the filenames with extension .xml in a directory and pass the name of the file, one by one, to another function.

Please help me out.

Regards.
Saurabh
As a warning, xml can be tricky to handle for various reasons:
1) it could all be on a single line - which means many unix utilities will not handle properly.
2) white space between tags is totally allowed, or optional (see #1)
3) It could be in "uni-code" which means there could be binary zeroes between every other character.

so have fun with the variations.
Reply With Quote
  #4  
Old 01-21-2008
Registered User
 

Join Date: Sep 2006
Posts: 1,580
Quote:
Originally Posted by bhalotias View Post
Hi,

I want to write a script to read all the filenames with extension .xml in a directory and pass the name of the file, one by one, to another function.

Please help me out.

Regards.
Saurabh
ls *xml | while read -r file
do
function $file
done
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:35 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0