Sponsored Content
Top Forums Shell Programming and Scripting case statement based on file availability Post 51748 by Loriel on Saturday 29th of May 2004 05:34:00 PM
Old 05-29-2004
Thanks for the example. I follow the logic for making a list of existing files, but it's the case statement that is confusing me. I'm not sure what to put in the 'options' section (talk about irony - that's where you stopped). This is the output (no options selectable):

1) This.txt
2) That.txt
#?

If I select either option, it returns Invalid Selection.

Here's the code I used:
Code:
i=0
for item in This.txt TheOther.txt That.txt
do
	if [ -r $item ]; then
		existing[i]=$item
		let i++
	fi
done

select readme in "${existing[@]}"
do
	case "$readme" in
		$existing[1])	echo "This.txt";;
		$existing[2])	echo "Red Herring";;
		$existing[3])	echo "That.txt";;
		*	)	echo "Invalid Selection";;
	esac
done

 

7 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can I get an if statement to execute based on number of lines in a file?

I need to have an if statement in a script to run if there are certain processes running. Easiest way I can see to do this is to run a ps and grep the results based on what I am looking for: $ ps -ef | grep wtrs --- webtrend 5046 1 0 May 12 ? 0:28 /webtrends/versions/6.1/wtrs_ui... (6 Replies)
Discussion started by: LordJezo
6 Replies

2. Shell Programming and Scripting

case statement

hi all i'm writing a script and in it i need to prompt the user if the entered value is correct or not ,i wrote the following and its not working ,its executing the script even if i enter Y/N pls any help is appreciated echo "\nAre you sure you entered the right Destination Environment? y :... (5 Replies)
Discussion started by: bkan77
5 Replies

3. Shell Programming and Scripting

help with case statement

I am writing a script to pull diskspace information from our servers. Here is the script that I wrote: #!/bin/ksh for host in `cat /oper/hosts/esc.misc` do ssh -q -o ConnectTimeout=10 operator@$host df -h|grep "/dev/" |egrep '8%|9%|100%' | awk '{print H " " "at " $5 " with " $4 "... (1 Reply)
Discussion started by: rkruck
1 Replies

4. 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

5. Shell Programming and Scripting

Case Statement

Hey, guys I really need some help with a project. "Write a shell program that examines the command line arguments, counts and collects the number of options. Basically it has to collect and count the arguments that start with a "-" and the one's that don't start with a - I know I have to use... (2 Replies)
Discussion started by: sk192010`
2 Replies

6. Homework & Coursework Questions

Case Statement

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Hey, guys I really need some help with a project. "Write a shell program that examines the command line... (8 Replies)
Discussion started by: sk192010`
8 Replies

7. 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
DCENTVFY(1)						DICOM PS3 - Validate DICOM entities					       DCENTVFY(1)

NAME
dcentvfy - ACR/NEMA DICOM PS3 ... DICOM PS3 - Validate DICOM entities SYNOPSIS
dcentvfy " inputfile1 [ inputfile2 ... ]" [ -v|verbose|vv|veryverbose ] [ -f|-filelist filename ] DESCRIPTION
dcentvfy reads the named dicom files (and/or the files listed in the specified file), extracts patient, study, series and instance entity unique identifiers and then validates that the attribute values defined in the standard for those entities have consistent values for the same entity. OPTIONS
The description and verbose output go to standard error. The basic input switches are described in dcintro(1). Options specific to this program are: -v|verbose Describe as files are read and analyzed and the model of entity relationships to instances is built. -vv|veryverbose Describe the detailed behavior of comparison of each attribute for each entity for each instance. -f|filelist filename A file containing a list of DICOM input files (one filename per line). ENVIRONMENT
EXAMPLES
FILES
SEE ALSO
dciodvfy(1), dcintro(1) AUTHOR
Copyright (C) 1993-2010. David A. Clunie DBA PixelMed Publishing. All rights reserved. BUGS
DICOM PS3 28 September 2008 DCENTVFY(1)
All times are GMT -4. The time now is 11:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy