- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Compare two variables
Operating System - HP-UX
1820608
Members
1747
Online
109626
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- 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
тАО09-07-2009 10:46 PM
тАО09-07-2009 10:46 PM
Hi
I have a shell script:
#!/usr/bin/sh
NOW=`date +%b' '%e' '`
HR=22
SP=$NOW$HR
CHECK=`ll -tr /tmp/myfile*| awk ' { print $6,$7,substr
($8,1,2)}'|tail -n 1`
if [ "$SP" = "$CHECK" ]
then
{
echo "File did arrive at 22h00 today"
exit 0
}
else
{
echo "File did not arrive at 22h00 today"
exit 0
}
fi
I want to schedule this script to run at 22h05 to check if a new version of a file (myfile*) has arrived at 22h00.
No matter how I script the expression in the if statement it doesn't behave as expected.
What am I doing wrong?
Regards
Graham
I have a shell script:
#!/usr/bin/sh
NOW=`date +%b' '%e' '`
HR=22
SP=$NOW$HR
CHECK=`ll -tr /tmp/myfile*| awk ' { print $6,$7,substr
($8,1,2)}'|tail -n 1`
if [ "$SP" = "$CHECK" ]
then
{
echo "File did arrive at 22h00 today"
exit 0
}
else
{
echo "File did not arrive at 22h00 today"
exit 0
}
fi
I want to schedule this script to run at 22h05 to check if a new version of a file (myfile*) has arrived at 22h00.
No matter how I script the expression in the if statement it doesn't behave as expected.
What am I doing wrong?
Regards
Graham
Solved! Go to Solution.
- Tags:
- date
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2009 11:12 PM
тАО09-07-2009 11:12 PM
Re: Compare two variables
Your awk expression produces an output like "Sep 8 10", with a single space between each element.
However, the date command produces two spaces between "Sep" and "8". The "%e" format code for the "date" command always output exactly two characters.
MK
However, the date command produces two spaces between "Sep" and "8". The "%e" format code for the "date" command always output exactly two characters.
MK
MK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-07-2009 11:44 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-08-2009 02:00 AM
тАО09-08-2009 02:00 AM
Re: Compare two variables
Thanks,
This works (and tested with|xd):
NOW=`date +%b%e`
HR=22
SP=$NOW" "$HR
echo $SP
CHECK=`ll -tr /tmp/myfile*| awk ' { print $6,$7,substr($8,1,2)}'|tail -n
1`
echo $CHECK
if [ "$SP" = "$CHECK" ]
Thanks again.
This works (and tested with
NOW=`date +%b%e`
HR=22
SP=$NOW" "$HR
echo $SP
CHECK=`ll -tr /tmp/myfile*| awk ' { print $6,$7,substr($8,1,2)}'|tail -n
1`
echo $CHECK
if [ "$SP" = "$CHECK" ]
Thanks again.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP