?
Solved

How to modify a script to be NOT case sensitive when looking for a string

Posted on 2009-12-21
5
Medium Priority
?
338 Views
Last Modified: 2013-12-26
Guys ,
here's a cp pf my scripts I  just have to modify it to check for .end or .END

#!/bin/ksh
#
#       Scirpt to remove Inbound File watcher ".end" file
#
#       Parameters Needed
#
#       1. Base File Name
#       2. Location of Base File Name
#

#       Get the Input Parms

file=$1
dir=$2
dol=$


        stdir=`eval echo $dol$dir`
        cd $stdir
        sdir=$PWD
        sfile=`ls -1t ${file}*.end | head -1`
        source=$sdir/$sfile

if [[ ! -e $sfile ]]
then
        echo "$file does NOT exist, Please check"
        exit 43
fi

echo The file to be removed is $sfile
echo The Source Directory is $sdir

rm $source


Thanks..!!!!
0
Comment
Question by:HIONSPD
5 Comments
 
LVL 40

Expert Comment

by:omarfarid
ID: 26097725
you may pass the ls out put through grep -i

ls -1t | grep -i '.end'
0
 
LVL 7

Accepted Solution

by:
vikas_madhusudana earned 1000 total points
ID: 26097801
sfile=`ls -1t | grep -i  ${file}*.end | head -1`
0
 
LVL 68

Assisted Solution

by:woolmilkporc
woolmilkporc earned 1000 total points
ID: 26097874
... or use a regular expression

 sfile=$(ls -1t ${file}*.[eE][nN][dD] | head -1)

You will have noticed that I used the $( ) notation instead of the backticks ` `
It's simply better readable!

wmp

0
 

Author Comment

by:HIONSPD
ID: 26098653
Thank you all for your help, all good answers.
0
 

Author Closing Comment

by:HIONSPD
ID: 31668601
Thanks Again...!!!!
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

592 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question