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 and shell scripting languages 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 09:23 AM
bash: reading filenames from file warp17 Shell Programming and Scripting 0 03-04-2008 06:28 AM
reading long filenames from nero to AIX categoryzd UNIX for Dummies Questions & Answers 1 05-18-2006 11:57 AM
Adding an extension to a group of filenames pepintheshort UNIX for Dummies Questions & Answers 9 04-09-2004 09:11 PM
reading filenames inside a program j_t_kim UNIX for Dummies Questions & Answers 5 04-04-2002 03:13 PM

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 01-21-2008
bhalotias bhalotias is offline
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
  #2 (permalink)  
Old 01-21-2008
earnstaf earnstaf is offline
Registered User
  
 

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

Join Date: Feb 2007
Posts: 134
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.
  #4 (permalink)  
Old 01-21-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,553
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
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 10:51 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