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
Regex in if-then-else statement to match strings rakeshou UNIX for Dummies Questions & Answers 7 04-04-2008 03:30 PM
case statement bkan77 Shell Programming and Scripting 5 09-11-2007 06:54 PM
if statement to match * sivasenthil_k UNIX for Dummies Questions & Answers 3 09-20-2006 12:39 PM
Case Statement Zeta_Acosta Shell Programming and Scripting 19 04-06-2004 05:16 PM
case statement Bab00shka Shell Programming and Scripting 1 07-15-2002 06:31 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 04-05-2008
sunitachoudhury sunitachoudhury is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 36
How to match the last XML extension by using Case statement

Hi All,

I have a status.txt file which contains following three files.

1.xml
2.xml
3.xml


Now i have written a shell script 1.sh which contains the following

cat status.txt | while read filename
do
echo $filename
case "$filename" in
xml)
echo "running 1.xml"
;;
esac
done


now when i am running the above 1.sh file then i am getting the following output.

1.xml
2.xml
3.xml


But i am not getting the following output
running 1.xml
Can anybody told me that what is the wrong with this 1.sh code??

Should i check the /xml$/ for case statement??????


Thanks
  #2 (permalink)  
Old 04-05-2008
javeed7 javeed7 is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 34
Hi sunitha,
use this.

cat status.txt | while read filename
do
echo "here $filename"
case "$filename" in
*xml)
echo "running 1.xml"
;;
esac
done
  #3 (permalink)  
Old 04-05-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Also lose the Useless Use of Cat.


Code:
while read filename
do
  echo "here $filename"
  case "$filename" in
    *xml)
      echo "running $filename"  # ... I guess you mean
      ;;
  esac
done <status.txt

  #4 (permalink)  
Old 04-06-2008
sunitachoudhury sunitachoudhury is offline
Registered User
  
 

Join Date: Mar 2008
Posts: 36
Thanks

Hi javeed7/era,

Thanks a log.
Yes it is working absolutely fine.
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 07:26 PM.


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