Sponsored Content
Top Forums Shell Programming and Scripting Case statement in UNIX shell script Post 302967360 by rbatte1 on Tuesday 23rd of February 2016 07:29:03 AM
Old 02-23-2016
Could you write out the logical flow you are trying to achieve? It's all a bit confused and mixed up with which are variables and which are files. str3 is written to as a file and then you try to use it as a variable.

If you read in a variable fil and you are looking to test if it has a leading hyphen - then you can more simply do something like this:-

Code:
read "enter a file: "?fil
not_first="${fil#?}"              # Trim off first character from input
first="${fil%$notfirst}"          # Trim off all the other characters from input

case "$first" in.......


Does that help? If the statements don't make sense, then let me know and I will explain them.

Robin
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script automation using case statement

Hi, I'm trying to write a shell script that has a menu and then dependant on the selection, will automate some samba file transfer. The problem is when I run the code without the case statement it runs fine. but when I put the case statement in the only way I can get the code to run is to... (6 Replies)
Discussion started by: ianf
6 Replies

2. Shell Programming and Scripting

what is problem with this small shell script.. case statement related

Hi All, this small script is written to recognize user input character.. it is in small case .. upeer case or is a number... but when i input first capital letter say A.. it always gives small character.... what is the problem. #!/bin/bash echo "Enter the character" read a case $a in )... (2 Replies)
Discussion started by: johnray31
2 Replies

3. Shell Programming and Scripting

shell script case statement

In a case statement like below : case $rental in "car") echo "For $rental Rs.20 per k/m";; "van") echo "For $rental Rs.10 per k/m";; "jeep") echo "For $rental Rs.5 per k/m";; "bicycle") echo "For $rental 20 paisa per k/m";; *) echo "Sorry, I can not gat a $rental for you";;... (4 Replies)
Discussion started by: sriram003
4 Replies

4. UNIX for Dummies Questions & Answers

case statement in UNIX scripting (ksh)

Hi, I have a script like below : #!/bin/ksh echo "Do you want to export all docs ?" read alld echo "Do you want to export template or report only " read temr case && ] #arguments ;; case && ] #arguments ;; case && ] #arguments ;; (4 Replies)
Discussion started by: luna_soleil
4 Replies

5. Shell Programming and Scripting

Shell case statement

echo -e "Select: \c" read IN pattern="1-20" case $IN in ) echo "Selected: $IN" ;; *) echo "Invalid selection: $IN" ;; esac # sh test Select: 10 Invalid selection: 10 # sh test Select: 2 (6 Replies)
Discussion started by: Ikon
6 Replies

6. Shell Programming and Scripting

Trouble in getting user input while using CASE statement in UNIX

i want to get user input like this please tell which option to chose 1. mango 2. tango 3. rango if user chooses mango then it should execute a set of statements and again ask like this what do you want to do 1.add 2.subtract 3.exit when i choose exit it should goto my previous menu... (4 Replies)
Discussion started by: s.deepak
4 Replies

7. Shell Programming and Scripting

Help on case to call recursively in UNIX Shell Script

Hi, I am New to Unix Shell Scripting basically, i need some help in achieving a case statement in Shell script to call recursively That is if case having like 1 2 3 4 options , if user inputs 1 and gets executed case should ask for options again but user should not input the same input value 1,... (7 Replies)
Discussion started by: karthikram
7 Replies

8. Shell Programming and Scripting

Using shell to generate case statement

Hi Gurus, I have a very weird requirement and have no clue to resolve the issue. please help me get out this difficulty below two tables, table1 contains the column name. D means this column used for the rule. for example: rule 0 is all columns have value, rule1 is col3 and col7 have no value.... (2 Replies)
Discussion started by: Torhong
2 Replies

9. Shell Programming and Scripting

Shell scripting with case statement

Foe example we have three environments int,qa and prod.Each environment has some number of servers. int=Server1,Server2,Server3 qa=Server4,Server5,Server6 prod=Server7,Server8,Server9 echo "Enter the Environment i.e int,qa,prod" read env case $env in int) ## Need command where all the... (9 Replies)
Discussion started by: nareshreddy443
9 Replies

10. Shell Programming and Scripting

Shell script run in a case statement call to run a php file, also Perl

Linux System having all Perl, Python, PHP (and Ruby) installed From a Shell script, can call a Perl, Python, PHP (or Ruby ?) file eg eg a Shell script run in a case statement call to run a php file, also Perl or/and Python file??? Like #!/usr/bin/bash .... .... case $INPUT_STRING... (1 Reply)
Discussion started by: hoyanet
1 Replies
CXREF(1)						      General Commands Manual							  CXREF(1)

NAME
cxref - cross reference C source files SYNOPSIS
cxref [ -FSCcfis ] [ -w width ] [files] DESCRIPTION
Cxref reads the named C source files and produces on the standard output a cross reference of all the identifiers and constants in the files. Constants are integer constants (12, 0421, 0x1A), floating point constants (123.45, 0.2e-4), string constants ("this is a string "), and character constants ('a', '33'). Identifiers, character constants, and string constants are sorted lexicographically, i.e. according to the machine collating sequence (7-bit ASCII on the Vax or the Pyramid). Integer and floating point constants are sorted numerically. The trailing 'l' or 'L' on long integer constants will not show up in the output listing. If no files are named, cxref reads the standard input. For multiple files, the argument "-" (a single dash) indicates that the standard input should be read at that point. If arguments are given, they must come before any file names. Cxref recognizes the following arguments: -F Fold case in comparison. By default, case is distinct in comparison of identifiers and string and character constants. (cxref simply passes the "-F" option on to sort(1) as "-f".) -S Cross reference all files separately. The default action is to cross reference all named files together. -c Leave character constants out of the cross reference listing. -f Leave floating point constants out of the cross reference listing. -i Leave integer constants out of the cross reference listing. -s Leave string constants out of the cross reference listing. -C Leave all constants, character, string, integer, and floating point, out of the cross reference listing. By default, all types of constants are included in the cross reference. -w width Make the output be width columns wide. The output width will never be less than 51 or more than 132 columns. Cxref silently adjusts incorrect settings to the nearest allowable setting. If no width is specified, the output will default to 80 columns wide. Cxref does not include #include files, or expand macro definitions. Files named in #include lines can be listed on the command line if they should also be cross referenced. If a quoted string has an escaped newline in it (see ``The C Programming Language'', page 181, or Section 2.5 of the C Reference Manual), it will show up inside the string in the output listing as N. This is to make it visible to the programmer, and to keep the various fil- ters which Cxref uses to actually do the work from getting terribly confused. Cxref is best run in the background, with its output redirected into a file or the line printer spooler lpr(1), since it reads all the named files, using sort(1) as an intermediate pass. The sorting can take time which the user can probably put to more productive use. DIAGNOSTICS
Self explanatory. BUGS
Systems running UNIX 4.0 and later already have a program named cxref. Therefore, on those systems, this program should be renamed. Cxref does not do any formatting on its output (other than to insure that it writes the proper number of columns), so it should probably be run piping its output into pr(1). Floating point constants are converted to a common format for sorting, therefore they may appear in the output in a format different from (but numerically equivalent to) their form in the original source code. SEE ALSO
lex(1), lpr(1), pr(1), sort(1) FILES
/tmp/cxr.$$.* temporary files for integer and floating point contstants. Cxref removes these files when it is through. AUTHOR
Arnold Robbins School of Information and Computer Science Georgia Institute of Technology Atlanta, Geogia 30332 UUCP: gatech!arnold CSNET: arnold@gatech ARPANET: arnold%gatech.csnet@csnet-relay.arpa Copyright (c) 1984 by Arnold Robbins. All rights reserved. This program may not be sold, but may be distributed provided this notice is included. Georgia Tech CXREF(1)
All times are GMT -4. The time now is 07:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy