The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script needed to select and delete lower case and mixed case records abhilash mn Shell Programming and Scripting 1 03-17-2008 08:00 AM
creating conditional logs sonali007 UNIX for Dummies Questions & Answers 0 10-01-2007 05:30 PM
Conditional Date Script cpd259 Shell Programming and Scripting 2 06-21-2007 02:01 PM
Confusion over a small conditional script amit4g Shell Programming and Scripting 2 06-13-2007 09:41 AM
lower case to upper case string conversion in shell script dchalavadi UNIX for Dummies Questions & Answers 3 05-29-2002 01:07 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-21-2005
soccerstr1 soccerstr1 is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 2
creating a script using the case conditional

hello, i am a newbie who is just starting to use liunx, and I need to accept a string from the terminal and use case to echo a suitable message if the string doesn’t have at least 10 characters. Also, how would I do the same thing using expr?
  #2 (permalink)  
Old 02-21-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
expr is not really needed with bash. It is faster to use bash's built-ins. And "case" is not a great choice either. How about:

((${#var}<10)) && echo too short
  #3 (permalink)  
Old 02-21-2005
soccerstr1 soccerstr1 is offline
Registered User
  
 

Join Date: Feb 2005
Posts: 2
thanx, that works for me as well. do you know what the script would look like using the case conditional?
  #4 (permalink)  
Old 02-21-2005
bhargav's Avatar
bhargav bhargav is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2004
Location: USA
Posts: 511

Code:

echo "read input"
read str


case $((${#str}<10)) in
1)
    echo "too short "
     ;;
*)
    echo "ok now .."
    ;;

Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 10:15 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0