Sponsored Content
Full Discussion: Case switching
Top Forums Shell Programming and Scripting Case switching Post 302943386 by Tuxidow on Friday 8th of May 2015 04:47:11 AM
Old 05-08-2015
Case switching

Hello Folks

I am writing this simple program but I am stuck at this point. Here is the snippet from my script where I have issues.

Code:
3)     echo "Current Directory:   $(pwd)                Menu 3"

      echo -e "Enter a file name\n"
      read fname
      if [ -f $name ]
      then

              if [ -x $name ]
              then
                cat $name
              else
                echo "You do not have access to file $name"
              fi
      else
                 echo "File $name doesn't exist"
        
                echo -e "Press Enter to return to the Main Menu\c"
                read dummy
        fi
;;

4)      clear
        
        echo "Current Directory:   $(pwd)                Menu 4"

        echo  -e "Enter a directory name\n"
        read dname
        if [ -d $dname ]
        then
                cd $dname
                if [ $? -eq 0 ]
                then
                        continue
                else
                        echo "Directory $dname not accessible"
        
                fi
        else
                echo "Subdirectory $dname does not exist."
        
                echo -e "Press Enter to return to the Main Menu\c"
                read dummy
        fi

This is a section of the script where it takes entry either 3 or 4. If 3 is selected it prompts for the user to enter filename and if the user is hitting just enter and not any filename, it should return to main menu. But that's not happening, its just looping around and waiting for an input. But if 4 is selected and an enter is pressed with out directory name it goes to that cd $dname part and moves to main menu. Since $dname is empty as the user has not provided any value it goes to home directory of the user.

My requirement is that the script should go back to main menu if the user hits just "enter" with out any value. How can I achieve that?
 

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. Shell Programming and Scripting

how to convert value in a variable from upper case to lower case

Hi, I have a variable $Ctrcd which contains country names in upper case and i want to convert them into lower case. I have tried so many solutions from already existing threads but couldn't get the correct one. Can anybody help me with this..... Thanks a lot.. (2 Replies)
Discussion started by: manmeet
2 Replies

4. Shell Programming and Scripting

Script to Convert Upper case to Lower case

Hi All I have a script which extracts values from a Database (A persons name) and puts it into a variable in my script IE: $NAME However the Value in the DB is all in uppercase and contains the users first name and last name EG: > echo $NAME GRAHAM BOYLE > What I need is only the... (7 Replies)
Discussion started by: grahambo2005
7 Replies

5. Shell Programming and Scripting

data array needs to change upper case to lower case

Hi all, i have a data array as followes. ARRAY=DFSG345GGG ARRAY=234FDFG090 ARRAY=VDFVGBGHH so on.......... i need all english letters to be change to lower case. So i am expecting to see ARRAY=dfsg345ggg ARRAY=234fdfg090 ARRAY=vdfvgbghh so on........ If i have to copy this data in... (8 Replies)
Discussion started by: usustarr
8 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

Change first letter of a word from lower case to upper case

Hi all, I am trying to find a way to change first letter in a word from lower case to upper case. It should be done for each first word in text or in paragraph, and also for each word after punctuation like . ; : ! ?I found the following command sed -i 's/\s*./\U&\E/g' $@ filenamebut... (7 Replies)
Discussion started by: georgi58
7 Replies
ldns(3) 						     Library Functions Manual							   ldns(3)

NAME
ldns_dname_compare, ldns_dname_interval- SYNOPSIS
#include <stdint.h> #include <stdbool.h> #include <ldns/ldns.h> int ldns_dname_compare(const ldns_rdf *dname1, const ldns_rdf *dname2); int ldns_dname_interval(const ldns_rdf *prev, const ldns_rdf *middle, const ldns_rdf *next); DESCRIPTION
ldns_dname_compare() Compares the two dname rdf's according to the algorithm for ordering in RFC4034 Section 6. dname1: First dname rdf to compare dname2: Second dname rdf to compare Returns -1 if dname1 comes before dname2, 1 if dname1 comes after dname2, and 0 if they are equal. ldns_dname_interval() check if middle lays in the interval defined by prev and next prev <= middle < next. This is usefull for nsec check- ing prev: the previous dname middle: the dname to check next: the next dname return 0 on error or unknown, -1 when middle is in the interval, +1 when not AUTHOR
The ldns team at NLnet Labs. Which consists out of Jelte Jansen and Miek Gieben. REPORTING BUGS
Please report bugs to ldns-team@nlnetlabs.nl or in our bugzilla at http://www.nlnetlabs.nl/bugs/index.html COPYRIGHT
Copyright (c) 2004 - 2006 NLnet Labs. Licensed under the BSD License. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. SEE ALSO
ldns_dname_is_subdomain. And perldoc Net::DNS, RFC1034, RFC1035, RFC4033, RFC4034 and RFC4035. REMARKS
This manpage was automaticly generated from the ldns source code by use of Doxygen and some perl. 30 May 2006 ldns(3)
All times are GMT -4. The time now is 05:31 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy