- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: Problem with string Comparison
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 07:29 AM
тАО07-28-2006 07:29 AM
Sorry for such a basic question. But still don't seem to get this working.
I get a fiename as an argument to the script and based on the file name, I need to rename it with the date appended to it.
#!/bin/ksh
INFILE=$1
echo "The incoming filename is $INFILE"
DAYSTRING=`date +%Y%m%d`
TIMESTRING=`date +%H%M%S`
if [ "$INFILE" = "prod_h_datafile_???.txt" ]
then
echo "Match Found"
OUTFILE=${DAYSTRING}${TIMESTRING}_hvendr.sig
fi
echo "The outgoing filename is $OUTFILE"
The script seeems to be working fine if I remove the ??? from the if statement and add the actual number. But with the ???, the comparison always fails.
Please suggest.
TIA
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 07:43 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 07:48 AM
тАО07-28-2006 07:48 AM
Re: Problem with string Comparison
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 07:51 AM
тАО07-28-2006 07:51 AM
Re: Problem with string Comparison
there we go :)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 07:53 AM
тАО07-28-2006 07:53 AM
Re: Problem with string Comparison
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 08:22 AM
тАО07-28-2006 08:22 AM
Re: Problem with string Comparison
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 08:25 AM
тАО07-28-2006 08:25 AM
Re: Problem with string Comparison
if [ `echo ${INFILE} | grep "prod_h_datafile_[0-9]\{8\}\.txt$"` ]
live free or die
harry d brown jr
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 10:03 AM
тАО07-28-2006 10:03 AM
Re: Problem with string Comparison
Instead of using a regular expression with an 'if' use a 'case':
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 10:05 AM
тАО07-28-2006 10:05 AM
Re: Problem with string Comparison
Sorry, I clicked the wrong button!
Instead of using a regular expression with an 'if' use a 'case' statement. Thry this version of your script:
#!/usr/bin/ksh
INFILE=$1
echo "The incoming filename is $INFILE"
DAYSTRING=`date +%Y%m%d`
TIMESTRING=`date +%H%M%S`
case $INFILE in
prod_h_datafile_[0-9][0-9][0-9].txt )
echo "Match Found"
OUTFILE=${DAYSTRING}${TIMESTRING}_hvendr.sig
;;
* )
echo "NO match!"
;;
esac
echo "The outgoing filename is $OUTFILE"
...
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-28-2006 12:14 PM
тАО07-28-2006 12:14 PM
Re: Problem with string Comparison
if [[ "$INFILE" = prod_h_datafile_???.txt ]]
Note you can't quote the pattern.
- Tags:
- pattern