LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-07-2019, 10:52 AM   #16
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 2,652

Rep: Reputation: Disabled

Quote:
Originally Posted by michaelk View Post
Ouch, nevermind that method...
I eventually figured out how tsch likes its RegExes (thanks for leading me down the wrong path, StackExchange), and this seems to work:
Code:
set number=$argv[1]
echo $number
if ( $number =~ {[0-1][0-9],2[0-3]}:[0-5][0-9] ) then
  echo "time is valid"
else
  echo "not valid"
endif
 
Old 10-07-2019, 11:00 AM   #17
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 21,944

Rep: Reputation: 5810Reputation: 5810Reputation: 5810Reputation: 5810Reputation: 5810Reputation: 5810Reputation: 5810Reputation: 5810Reputation: 5810Reputation: 5810Reputation: 5810
Quote:
Originally Posted by Ser Olmy View Post
I eventually figured out how tsch likes its RegExes (thanks for leading me down the wrong path, StackExchange), and this seems to work:
Code:
set number=$argv[1]
echo $number
if ( $number =~ {[0-1][0-9],2[0-3]}:[0-5][0-9] ) then
  echo "time is valid"
else
  echo "not valid"
endif
Nice...like that better than my split-it-apart method.
 
1 members found this post helpful.
Old 10-07-2019, 11:35 AM   #18
DoME69
Member
 
Registered: Jan 2008
Posts: 181

Original Poster
Rep: Reputation: 16
This work for me based on @Ser Olmy suggestion.


Code:
set arg = $argv[1]

set split_time = ($arg:as/:/ /)

    if (($split_time[1] > 24 | $split_time[2] > 59) | ($split_time[1] == 24 | $split_time[2] > 0)) then 
        echo "\nError: Time $argv[1] not legal time!"
        exit
    endif
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Patents, Legal Collaboration and our Legal Summit LXer Syndicated Linux News 0 03-15-2012 07:11 PM
LXer: Patents, Legal Collaboration and our Legal Summit LXer Syndicated Linux News 0 03-15-2012 08:50 AM
tcsh script: can you time parts of the script? BrianK Programming 7 02-02-2010 07:20 PM
Partition check, check double check Vincentius Linux - General 0 12-25-2004 05:47 AM
Boot disk; check. CD in drive; check. Doesn't work; check. Hal DamnSmallLinux 7 02-04-2004 02:10 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration