To be honest i think you should change your programs logic completely: You enter a character (or word), some values are legal, ALL others are not. You do not need the functionality of a while-loop at all, so why should you use it?
How about the following, which is easily extensible:
This should also be easier to read and to maintain.
If you want to use the code part as a device to process the commandline you could also resort to the getopts-program. Have a look at the manpage for it and if this fits your requirements and you still have problems applying it come back and ask again.
I am trying to take input from a file and direct it into a bash script. This script is meant to be a foreach loop. I would like the script to process each item in the list one by one and direct the output to a file.
# cat 1loop
#!/bin/bash
# this 2>&1 to redirect STDERR & STDOUT to file... (4 Replies)
Hi All,
I wrote one simple for loop shell script which prints number..but this loop is infinite...but its taking lot of CPU (15.7) %. if i am using sleep cmd then cpu usage become 0.4 %. Is there anyway to reduce this CPU usage without using sleep cmd?
i dont want 2 use sleep cmd... (7 Replies)
I'm new from UNIX scripting. Please help.
I have about 10,000 files from the $ROOTDIR/scp/inbox/string1 directory to compare with the 50 files from /$ROOTDIR/output/tma/pnt/bad/string1/ directory and it takes about 2 hours plus to complete the for loop. Is there a better way to re-write the... (5 Replies)
I'd like to
1. Check and compare the 10,000 pnt files contains single record from the /$ROOTDIR/scp/inbox/string1 directory against 39 bad pnt files from the /$ROOTDIR/output/tma/pnt/bad/string1 directory based on the fam_id column value start at position 38 to 47 from the record below. Here is... (1 Reply)
Gurus,
I need to read a line from a file and strip the characters from it and compare the stripped value with the value I pass to the script while executing it. Below is the code for the same. But when i execute the code, it is throwing an error.
#!/bin/ksh
. /home/.i_env
... (14 Replies)
How do I go about amending this simple script that prompts for a yes/no response so that if neither Y or N are entered it will loop back back to the original prompt
#!/bin/ksh
echo "Enter yes of no"
read answer
if
then
echo "You selected yes"
elif
then
echo "You selected no"
elif... (5 Replies)
I have below files under dir_a and dir_b and i want to sort out number of dir_a and dir_b files seperately and if i do the grep it should retrun 2 files in dir_a and 1 file in dir_b.
/dir_a/12345678
/dir_a/87654321
/dir_a/dir_b/12345687
But i am getting cat file|grep dir_a|wc -l
3... (6 Replies)
Hi,
I am new to unix/linux scripting.
I have a text file, listlib.txt where the content:
lib1_23
lib34_a
ab_li_lab
I need to generate a file (.log) of each cell. I am planning to create a (.csh) script that will have for loop with variable taken from listlib.txt. As for now, i have no... (4 Replies)
Discussion started by: mmaz
4 Replies
LEARN ABOUT OSF1
pac
pac(8) System Manager's Manual pac(8)NAME
pac - Outputs printer/plotter accounting information
SYNOPSIS
pac [-cmrs] [-p price] [-P printer] [name]
FLAGS
Sorts output according to the computed cost instead of alphabetically according to user. Groups all printing charges for the user speci-
fied by name, without regard for the host machine from which printing was invoked. The dollar amount charged per unit of output specified
by price. The default dollar amount charged is $0.02 per unit. Specifies the printer for which accounting records are produced. Alterna-
tively, the system selects the printer named with the PRINTER environment variable, or the default printer lp0. Reverses the sorted order,
so that records are listed alphabetically from z to a, or in descending order by computed cost when this flag is used with the -c flag.
Writes printer accounting information to a summary file. You must specify the -P flag and printer name (or synonym) when you use this flag.
Output is made to a file that is associated with the af entry for the specified printer in the /etc/printcap file. This file is located in
the /usr/adm directory. The file name is usually the af accounting file name, with the letters _sum (summary) appended, for example:
/usr/adm/lp2acct_sum. Accounting information is in three unheaded columns in the format: pages/feet machinename:username runs
DESCRIPTION
When printer accounting is enabled in the /etc/printcap file, and you use the pac command in a shell script or from the standard input, pac
outputs printer/plotter accounting records to the standard output for each user of the printer specified with the -P flag and printer name
or for users specified with the name parameter. The unit used for printer accounting is the number of pages printed. However, for raster
devices (such typesetters, and plotters) length in feet of print medium (film, for example) is the unit used. Output units are expressed
both as the number of units used and the charge in dollars according to the price specified with -p flag and price amount per unit. The
printer/plotter accounting output has the following column headings and format: Login pages/feet runs price
chicken:rcb 19.00 2 $ 0.38 sardine:jmp 22.00 3 $ 0.44 hunch:lucy 53.00 12 $
1.06 stovetop:suki 1.00 1 $ 0.02 newspaper:myralou 834.00 202 $ 16.68 wimbledon:nhk 69.00 20 $
1.38 norfolk:sophie 184.00 17 $ 3.68
There are four fields, each with its own column heading, in each record of the default output produced by the pac command: 1) the machine
from which the print command was entered and login name is entered in the Login column; 2) the number of pages or feet of paper output is
entered in the page/feet column; 3) the number of times the printer was used is entered in the runs column; and 4) the cost computed at the
default or specified price is entered in the price column.
EXAMPLES
To print printer/plotter accounting information for all users of default printer lp0 to the standard output device, enter: /usr/sbin/pac
Output is sorted alphabetically according to machine name and username. The number of printed pages or feet of output paper used and the
charge per foot of paper or page is computed at the default dollar amount of $0.02 per page because no flags are specified. To write
accounting records for printer printer1 in a summary file, enter the following line as a superuser or as adm: /usr/sbin/pac -Pprinter1 -s
Summary information is written to the file /var/adm/printer1acct_sum. To produce accounting information for users lucy, suki and myralou
for pages printed on printer putnam408, enter: /usr/sbin/pac -Pputnam408 lucy suki myralou
FILES
Specifies the command path Accounting information summary file. Printer information summary file, where printcap symbol af defines the
name of the accounting file.
RELATED INFORMATION
Commands: acct(8), acctcms(8), acctcom(8), acctcon(8), acctmerg(8), acctprc(8), printcap(4), runacct(8) delim off
pac(8)