Sponsored Content
Special Forums UNIX Desktop Questions & Answers Specifying a range within case/esac Post 302444759 by Orbient on Thursday 12th of August 2010 05:40:44 PM
Old 08-12-2010
Quote:
Originally Posted by scottn
Hi.

You could shorten it as such:

Code:
time1=`date +%l:%M`

case `date +%H` in
0[0-4]) time2="in the early morning" ;;
0[5-9]|1[01]) time2="in the morning" ;;
1[2-6]) time2="in the afternoon" ;;
1[7-9]) time2="in the evening" ;;
2[0-3]) time2="at night" ;;
esac

echo "The time is$time1 $time2"

Thank you so much!

Just one more thing, could you explain what is going on in this line of your script? Specifically, the |1[01] part.

Quote:
0[5-9]|1[01]) time2="in the morning"
Edit: Actually, just worked it out. Thanks again!

By the way, is there an easy way to get the date command to show the st/nd/rd/th suffix for days?
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

lower case to upper case string conversion in shell script

How can convert a Lower case variable value to an upper case in the kron shell script. (3 Replies)
Discussion started by: dchalavadi
3 Replies

2. Shell Programming and Scripting

Script needed to select and delete lower case and mixed case records

HELLO ALL, URGENTLY NEEDED A SCRIPT TO SELECT AND DELETE LOWER AND MIXED CASE RECORDS FROM A COLUMN IN A TABLE. FOR EXAMPLE : Table name is EMPLOYEE and the column name is CITY and the CITY column records will be: Newyork washington ... (1 Reply)
Discussion started by: abhilash mn
1 Replies

3. UNIX for Dummies Questions & Answers

how to break within a case/esac and stay in script

Wrote the following loop to but if I use exit, then I break entirely from my script, but instead I want to break from the case/esac and go to the next line in my script. I guess I need to know how to exit gracefully from a "while (true). Also, how can I allow the user to enter upper or lowercase... (4 Replies)
Discussion started by: tumblez
4 Replies

4. Shell Programming and Scripting

print range between two patterns if it contains a pattern within the range

I want to print between the range two patterns if a particular pattern is present in between the two patterns. I am new to Unix. Any help would be greatly appreciated. e.g. Pattern1 Bombay Calcutta Delhi Pattern2 Pattern1 Patna Madras Gwalior Delhi Pattern2 Pattern1... (2 Replies)
Discussion started by: joyan321
2 Replies

5. UNIX for Dummies Questions & Answers

Using a case statement with a range of numbers

Hey guys, I'm trying to setup a case statement that checks a value against 5 separate ranges of numbers. Here are the things I've tried with no success. case "$AGE" in "<10") echo "You're in this decade.";; "") echo "You're in this decade.";; "") echo "You're in... (5 Replies)
Discussion started by: fufaso
5 Replies

6. Shell Programming and Scripting

sed ignoring case for search but respecting case for subtitute

Hi I want to make string substitution ignoring case for search but respecting case for subtitute. Ex changing all occurences of "original" in a file to "substitute": original becomes substitute Origninal becomes Substitute ORIGINAL becomes SUBSTITUTE I know this a little special but it's not... (1 Reply)
Discussion started by: kmchen
1 Replies

7. Shell Programming and Scripting

[Solved] Change Upper case to Lower case in C shell

Is there a command that can switch a character variable from UPPER case to lower case? like foreach AC ( ABC BCD PLL QIO) set ac `COMMAND($AC)` ... end Thanks a lot! (3 Replies)
Discussion started by: rockytodd
3 Replies

8. Shell Programming and Scripting

Conversion from Upper Case to Lower Case Condition based

Hello Unix Gurus : It would be really appreciative if can find a solution for this . I have records in a file . I need to Capitalize the records based on condition . For Example i tried the following Command COMMAND --> fgrep "2000YUYU" /export/home/oracle/TST/data.dat | tr '' ''... (12 Replies)
Discussion started by: tsbiju
12 Replies

9. Shell Programming and Scripting

Case -- esac number of arguments problem

hi Scripting experts, I am using case..esac in my script .. I have given 6 option..e.g. 1 2 3 4 5 and *, howerver my script works welll for 1st 4 options but for 5 it considers * and exists. Is there a maximum limit on number of options given for case ..esac? (1 Reply)
Discussion started by: sdgawande
1 Replies
Arch::RevisionBunches(3pm)				User Contributed Perl Documentation				Arch::RevisionBunches(3pm)

NAME
Arch::RevisionBunches - manage bunches of related revisions SYNOPSIS
use Arch::RevisionBunches; use Arch::Tree; my $rb = Arch::RevisionBunches->new; my $tree = Arch::Tree->new(".", own_logs => 1); $rb->add_revision_descs($tree->get_history_revision_descs); $rb->rebunch(25); # the default is 50 foreach my $bunch ($rb->get) { print "$bunch->{version} "; print " $_->{name} $_->{summary} " foreach @{$bunch->{revision_descs}}; } foreach my $bunch ($rb->reverse_revision_descs->rebunch(30)) { print $bunch->{name1}; print " .. $bunch->{name2}" if $bunch->{name2}; print " ($bunch->{daysago1}"; print " .. $bunch->{daysago2}" if $bunch->{name2}; print " days ago) "; } DESCRIPTION
This class helps front-ends to group revisions. Such grouping is essential when, for example, the version to be shown contains thousands of revisions. The front-end may decide to show expandable bunches of 100 revisions each. There is a support for revision descriptions (summary, date, creator, email, and in some cases associated the file name and/or the associated version). There is a constraint by convention, one bunch may only contain revisions of the same version, and the ones associated with the same file if applicable. It is possible to define an order of versions. It is possible to recreate bunches (rebunch) using a different number of revisions. The constraint defines the actual number of revisions in different bunches, it is not guaranteed to be the same. METHODS
The following methods are available: new, init, add_revision_descs, versions, rebunch, get, clear, reverse_revision_descs, versions, filepaths. new [%args] Construct Arch::RevisionBunches object. The %args are passed to init method. init [%args] The %args keys may be bunch_size (to use as the default bunch size instead of 50), max_sumlen (maximal summary length to keep including trailing ellipsis, must be greater than 5), version (if set, then all revisions are assumed to be of one version, otherwise multiple versions are assumed), final_revision and final_filepath (the final revision and filepath for which the revision bunches are constructed). These last two %args keys are not really used yet. add_revision_descs [%constant_fields] Add revision descriptions that is arrayref of hashes. See other classes that return such revision descriptions. If the %constant_fields is given, then add these to all revision descriptions (rarely needed). Return the object, this enables chaining of get or rebunch method call. rebunch [bunch_size] Group newly added revisions if no bunch_size is specified. Otherwise regroup all revisions using a given bunch_size. The default bunch size may be specified in the constructor. Return the same get does. get Return bunches that is arrayref in scalar context, array in list context. Each bunch is hashref with keys: revision_descs name1 daysago1 time1 tz1 name2 daysago2 time2 tz2 size num_creators num_other_creators main_creator main_email creator name date summary and optionally "version", "is_missing" and "filepath" if applicable. This method implicitly calls rebunch with no parameter if new revision descriptions were added that are not bunched yet. clear Clear all bunches and their revision descriptions. reverse_revision_descs Effectivelly empty all revision descriptions (both old and new) and readd them in the reverse order. Return the object, this enables chaining of get or rebunch method call. versions Return distinct versions participated in all bunches. Return empty arrayref if not applicable, i.e. if version is given in the constructor. filepaths Return distinct filepaths participated in all bunches. Return empty arrayref if not applicable, i.e. if revision descriptions have no filepath. BUGS
Waiting for your reports. AUTHORS
Mikhael Goikhman (migo@homemail.com--Perl-GPL/arch-perl--devel). SEE ALSO
For more information, see Arch::Tree, Arch::Log, Arch::Session, Arch::Library. perl v5.10.1 2005-02-21 Arch::RevisionBunches(3pm)
All times are GMT -4. The time now is 08:04 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy