Sponsored Content
Full Discussion: Code Consolidation
Top Forums UNIX for Dummies Questions & Answers Code Consolidation Post 302137126 by misterpinkey on Saturday 22nd of September 2007 09:42:34 AM
Old 09-22-2007
Code Consolidation

My code currently looks like this:

#!/usr/bin/ksh
clear

while true
do
clear

echo "Menu"
echo " 1. WPPHA1"
echo " 2. WPPHA2"
echo " 3. WPPHA3"
echo " 4. WPPHB1"
echo " 5. WPPHB2"
echo " 6. WPPHC0"
echo " 7. WPPHD0"
echo " 8. WPPHD1"
echo " 9. WPPHD2"
echo "10. WPPHD3"
echo "11. Exit"
echo

read choice
case $choice in
1)
clear
cp /usr/asm/data.1182/user_data/reticle_base/reticle_base /usr/asm/data.1182/user_data/reticle_base/reticle_base_temp
mv /usr/asm/data.1182/user_data/data_A01/user_data/reticle_base/reticle_base_temp /usr/asm/data.1182/user_data/data_A01/user_data/reticle_base/reticle_base
true
echo "Copy successful to WPPHA1"
read continue
$continue
clear
exit
;;

2)
clear
cp /usr/asm/data.1182/user_data/reticle_base/reticle_base /usr/asm/data.1182/user_data/reticle_base/reticle_base_temp
mv /usr/asm/data.1182/user_data/data_A02/user_data/reticle_base/reticle_base_temp /usr/asm/data.1182/user_data/data_A02/user_data/reticle_base/reticle_base
true
echo "Copy successful to WPPHA2"
read continue
$continue
clear
exit
;;

**it keeps doing this exact thing for all choices until 11, which just exits. The only differences for each choice are the things I highlighted in bold (the 3 characters which are short for the tool name & the echo prompt saying that the copy was successful. Is there a way to use a loop or something to consolidate this to make it smaller?

esac
done


Thanks,
MP
 

2 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Apache Subnet consolidation script/routine help needed

I have a rather simple routine that I would like to fine tune. I am having scripters block if that exists. Trying to tally up that amount of subnets after I performed an awk and uniq from zipped apache logs. For instance, on a solaris 10 system: This does work gunzip -c access_log1.200834.gz |... (2 Replies)
Discussion started by: NYG71
2 Replies

2. UNIX for Dummies Questions & Answers

RRDtool consolidation not going as expected

Hello all, I am new to RRDtool and have made a RRDtool database with one data-source. Information of this data-source is stored in four different RRA's with different intervals for different time spans. Database create command: rrdtool create /root/mde.rrd --step 300 \... (2 Replies)
Discussion started by: ArtOfLosing
2 Replies
echo(1B)					     SunOS/BSD Compatibility Package Commands						  echo(1B)

NAME
echo - echo arguments to standard output SYNOPSIS
/usr/ucb/echo [-n] [argument] DESCRIPTION
echo writes its arguments, separated by BLANKs and terminated by a NEWLINE, to the standard output. echo is useful for producing diagnostics in command files and for sending known data into a pipe, and for displaying the contents of envi- ronment variables. For example, you can use echo to determine how many subdirectories below the root directory (/) is your current directory, as follows: o echo your current-working-directory's full pathname o pipe the output through tr to translate the path's embedded slash-characters into space-characters o pipe that output through wc -w for a count of the names in your path. example% /usr/bin/echo "echo $PWD | tr '/' ' ' | wc -w" See tr(1) and wc(1) for their functionality. The shells csh(1), ksh(1), and sh(1), each have an echo built-in command, which, by default, will have precedence, and will be invoked if the user calls echo without a full pathname. /usr/ucb/echo and csh's echo() have an -n option, but do not understand back-slashed escape characters. sh's echo(), ksh's echo(), and /usr/bin/echo, on the other hand, understand the black-slashed escape characters, and ksh's echo() also understands a as the audible bell character; however, these commands do not have an -n option. OPTIONS
-n Do not add the NEWLINE to the output. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), echo(1), ksh(1), sh(1), tr(1), wc(1), attributes(5) NOTES
The -n option is a transition aid for BSD applications, and may not be supported in future releases. SunOS 5.10 3 Aug 1994 echo(1B)
All times are GMT -4. The time now is 09:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy