Rather than wrestling with the shell to do this - make it easy on yourself and use Perl - for example, to only print the line if the user enters a 1....
Cheers
ZB
Hi all
Does anyone have a script that will allow me to stop inside a while read loop.
I want to pause the loop until a enter is pressed.
e.g.
While read line
do
echo something
if LINECOUNT > 40
then
read ENTER?"PRESS ENTER TO CONT..."
... (3 Replies)
I'm trying to understand if it's possible to create a set of variables that are numbered based on another variable (using eval) in a loop, and then call on it before the loop ends.
As an example I've written a script called question (The fist command is to show what is the contents of the... (2 Replies)
Hi all
Sorry for the basic question, but i am writing a shell script to get around a slightly flaky binary that ships with one of our servers. This particular utility randomly generates the correct information and could work first time or may work on the 12th or 100th attempt etc !.... (4 Replies)
Hi,
I am reading file records inside a while loop,
and want to update the record when certain condition is met.
How can I update a file while being read?
I want to avoid using temporary files, copy, rename, ...
while IFS=',' read -r f1 f2
do
function(f1,f2)
if
then
<add... (1 Reply)
Hello,
I have a set of files Xfile0001 - Xfile0021, and the content of this files (one at a time) needs to be printed between some line (lines start with word "Generated") that I am extracting from another file called file7.txt and all the output goes into output.txt. First I tried creating a for... (5 Replies)
I'm taking a unix class and need to countdown to 0 from whatever number the user inputs. I know how to do this with a while or until loop but using the for loop is throwing me off....
I know I can use an if-then statement in my for loop but can I include a while loop in my for loop? (3 Replies)
Hi there guys!
I was trying to do:
while read line; do
if ; then
read -p "Press Enter to continue..."
cont=0
fi
echo $line
let cont++
done < file.txt
However, I have read that the read -p would not work in a while loop...
I was wondering if there is any other way to... (2 Replies)
Hi,
This query is a part of a much more lengthy script.
I wish to look for all the files in a folder named "data" which in this case has two files i.e. plan.war and agent.properties. For all the files found under data I wish to ask the user as to where they wish copy the files to.
Below,... (14 Replies)
Hi everybody,
I am new at Unix/Bourne shell scripting and with my youngest experiences, I will not become very old with it :o
My code:
#!/bin/sh
set -e
set -u
export IFS=
optl="Optl"
LOCSTORCLI="/opt/lsi/storcli/storcli"
($LOCSTORCLI /c0 /vall show | grep RAID | cut -d " "... (5 Replies)
Discussion started by: Subsonic66
5 Replies
LEARN ABOUT SUNOS
lpq
lpq(1B) SunOS/BSD Compatibility Package Commands lpq(1B)NAME
lpq - display the content of a print queue
SYNOPSIS
/usr/ucb/lpq [-P destination] [-l] [ + [interval]] [ request-ID...] [user...]
DESCRIPTION
The lpq utility displays the information about the contents of a print queue. A print queue is comprised of print requests that are waiting
in the process of being printed.
lpq displays the following information to the standard output:
o the username of the person associated with a print request,
o the position of a print request in the print queue,
o the name of file or files comprising a print request,
o the job number of a print request, and
o the size of the file requested by a print request. File size is reported in bytes.
Normally, only as much information as will fit on one line is displayed. If the name of the input file associated with a print request is
not available, the input file field indicates the standard input.
The print client commands locate destination information using the printers database in the name service switch. See nsswitch.conf(4),
printers(4), and printers.conf(4) for details.
OPTIONS
The following options are supported:
-P destination Displays information about printer or class of printers (see lpadmin(1M)) . Specify destination using atomic or POSIX-style
(server:destination) names. See printers.conf(4) for information regarding the naming conventions for atomic names and
standards(5) for information regarding POSIX.
-l Displays information in long format. Long format includes the name of the host from which a print request originated in the
display.
+ [interval] Displays information at specific time intervals. Stops displaying information when the print queue is empty. Clears the
screen before reporting displaying the print queue. Specify interval as the number of seconds between displays. If inter-
val is not specified only executes once.
OPERANDS
The following operands are supported:
request-ID The job number associated with a print request.
user The name of the user about whose jobs lpq reports information. Specify user as a valid username.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
non-zero An error occurred.
FILES
/var/spool/print/[cd]f* Spooling directory and request files for jobs awaiting transfer.
/var/spool/lp/* LP print queue
$HOME/.printers User-configurable printer database
/etc/printers.conf System printer configuration database
printers.conf.byname NIS version of /etc/printers.conf
printers.org_dir NIS+ version of /etc/printers.conf
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWscplp |
+-----------------------------+-----------------------------+
SEE ALSO lp(1), lpc(1B), lpr(1B), lprm(1B), lpstat(1), lpadmin(1M), nsswitch.conf(4), printers(4), printers.conf(4), attributes(5), standards(5)SunOS 5.10 23 May 2003 lpq(1B)