Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Noob question: How to check the total number of inputs entered by user? Post 303042045 by jejemonx on Thursday 12th of December 2019 04:34:33 AM
Old 12-12-2019
I'm using the
Code:
read

command to read 3 inputs, namely num1, num2, and num3. I want to write a while loop that repeatedly asks for the correct number of inputs, which is 3.

Here's the pseudocode:
read user input here (must be 3)
while the number of inputs entered is less than or greater than 3, ask again for input.
Once it exits the while loop, do the rest of the script's purpose.

Last edited by rbatte1; 12-12-2019 at 10:10 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash : how do i check the user input and make sure is only chracter or only number ?

Bash : how do i check the user input and make sure is only character or only number ? (7 Replies)
Discussion started by: CheeSen
7 Replies

2. Shell Programming and Scripting

validating user entered date

I need the date validation. I searched in the google but i didn't find my requirements. requirements: 1) user has to enter the date in YYYY/MM/DD format 2) MM validations 3) DD validations. and if the month is april it should allow 30 days only and for May month it should allow 31 days like... (1 Reply)
Discussion started by: KiranKumarKarre
1 Replies

3. High Performance Computing

PBS - restrict total number of processors per user

Hello everyone! I am a bit inexperienced with administering queueing programs. I installed Torque (a PBS derivative) on a Linux cluster and it is running well. There is one annoying problem though: users can run massively parallel jobs and serial jobs too. Almost all users do a mix of the two. I... (0 Replies)
Discussion started by: gnuplot
0 Replies

4. Shell Programming and Scripting

Total noob script

Hi i am a total noob at shell scripting. i was wondering if somebody could help me with my script. i want the script to search the dev folder for the burner file because they are different between distrubutions? as i under stand it. this i the script. #!/bin/bash echo "Script för att bränna 360... (4 Replies)
Discussion started by: MatsO
4 Replies

5. Shell Programming and Scripting

only a number can be entered no letters?

ok the user can only enter a number if a letter is entered it shouldnt be accepted This is what i have so far read -p "How many cars to enter:" cars until do read -p "Invalid number. Please re-enter:" $tags done (5 Replies)
Discussion started by: gangsta
5 Replies

6. Shell Programming and Scripting

Help with sum total number of record and total number of record problem asking

Input file SFSQW 5192.56 HNRNPK 611.486 QEQW 1202.15 ASDR 568.627 QWET 6382.11 SFSQW 4386.3 HNRNPK 100 SFSQW 500 Desired output file SFSQW 10078.86 3 QWET 6382.11 1 QEQW 1202.15 1 HNRNPK 711.49 2 ASDR 568.63 1 The way I tried: (2 Replies)
Discussion started by: patrick87
2 Replies

7. Shell Programming and Scripting

How to accept command line argument as character or text if number is entered?

Hello Does the unix korn shell provide a function to convert number entered in command line argument to text or Character so that in next step i will convert Chr to Hex (6 Replies)
Discussion started by: aadityapatel198
6 Replies

8. Shell Programming and Scripting

Print Unknown Number of User Inputs in awk

Hello, I am new to awk and I am trying to figure out how to print an output based on user input. For example: ubuntu:~/scripts$ steps="step1, step2, step3" ubuntu:~/scripts$ echo $steps step1, step2, step3 I am playing around and I got this pattern that I want: ... (3 Replies)
Discussion started by: tattoostreet
3 Replies

9. Shell Programming and Scripting

How to check user entered correct file format or not?

Hi Experts, path=/db/files/ format=$1 User can enter any file format.compare the user file format with actual file format existed in the directory /db/files. User enter all characters as "A" apart from date format. example1: user will be entering the file format AAA_AA_YYYYMMDD.AAA Actual... (6 Replies)
Discussion started by: nalu
6 Replies

10. Shell Programming and Scripting

Total Noob BASH scripting question

Hello All, I have a file of ip addresses called activeips.txt What I'm trying to do is run a simple bash script that has a loop in it. The loop is a cat of the IP addresses in the file. The goal is to run 2 nmap commands to give me outputs where each address in the list has an OS... (11 Replies)
Discussion started by: Dirk_Pitt
11 Replies
FBB::OFoldStreambuf(3bobcat)					  Fold long lines				      FBB::OFoldStreambuf(3bobcat)

NAME
FBB::OFoldStreambuf - Folds long lines written to ostream SYNOPSIS
#include <bobcat/ofoldstreambuf> Linking option: -lbobcat DESCRIPTION
FBB::OFoldStreambuf is a specialization of FBB::OFilterStreambuf folding long lines written to an std::ostream object. The OFoldStreambuf writes the (folded) lines to a second ostream (the destination stream which is either used by or opened by the OFoldStreambuf object. Internally the OFoldStreambuf defines its actions using a little finite state automation distinguishing three states (INDENT, WS and NON_WS) and three character categories ( , other white space characters (space), and non-space characters). The nine combinations result- ing from these two sets are discussed below. OFoldStreambuf objects will never fold lines in the middle of series of non-blank characters (called a `word' below) but will always break a line at a white space character. The resulting lines will always appear to the right of a configurable left margin and to the left of a configurable right margin. There is a somewhat pathological exception to this: if a word is too long to fit in between the margins then the word will exceed the right hand margin. The indentation used for the left margins is configurable to either blanks (the default) or tabs. When tabs are used the width of a tab character is configurable, using a default of 8 positions in the destination stream. What follows is a description of the Finite State Automaton (FSA) defining what happens when various character types appear at its three states. The phrase `... is written' means that the described information is written to the ostream used or opened by the OFoldStreambuf object. OFoldStreambuf's initial state is INDENT: State char. description ----------------------------------------------------------------------- INDENT a new line character is written space the indentation is set; the space character is added to the indentation; next state: WS non-ws the character is added to the currently stored word; next state: NON_WS ----------------------------------------------------------------------- WS a new line character is written; stored white-space is erased; next state: INDENT space white space character is added to the currently stored space characters; non-ws the character is added to the currently stored word; next state: NON_WS ----------------------------------------------------------------------- NON_WS stored white space and word are written; a new line is written; next state: INDENT space stored white space and word are written; white space character is added to the currently stored space characters; next state: WS non-ws the character is added to the currently stored word; ----------------------------------------------------------------------- NAMESPACE
FBB All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB. INHERITS FROM
FBB::OFilterStreambuf ENUMERATION
The enumeration TabsOrBlanks is used to select tabs or blanks when writing the indentation. The default is blanks. When tabs are selected the display width of tabs characters can be configured as well (using the default of 8 positions for each tab-character. The enumeration has two values: o BLANKS: The default, indicating that the left margin is specified and written as a number of blanks; o TABS: Indicating that the left margin is specified and written as a number of tab-characters. The enumeration TrailingBlanks is used to configure the OFoldStreambuf object with respect to any trailing blanks that may appear on the final line. These trailing blanks can appear on the final line it it is not properly terminated with a newline character but instead ends in white space. By default these white space characters are ignored, but they may be kept as well. The enumeration has two values: o IGNORE_TRAILING_BLANKS: This indicates that trailing blanks appearing at the final line if it is not terminated by a newline should not be written to the destination std::ostream. This is the default used by OFoldStreambuf objects. o KEEP_TRAILING_BLANKS: This indicates that trailing blanks at the final line if it is not terminated by a newline should be written to the destination std::ostream CONSTRUCTORS
o OFoldStreambuf(size_t leftIndent = 0, size_t rightMargin = 80, TabsOrBlanks tob = BLANKS, TrailingBlanks tb = IGNORE_TRAIL- ING_BLANKS): This constructor initializes an OFoldStreambuf object but does not associate it with a destination stream. It can also be used as the default constructor. o OFoldStreambuf(char const *fname, size_t leftIndent = 0, size_t rightMargin = 80, TabsOrBlanks tob = BLANKS, TrailingBlanks tb = IGNORE_TRAILING_BLANKS): This constructor initializes an OFoldStreambuf object and opens (using std::ios::out) the destination stream using the name speci- fied as its fname argument. o OFoldStreambuf(std::ostream &stream, size_t leftIndent = 0, size_t rightMargin = 80, TabsOrBlanks tob = BLANKS, TrailingBlanks tb = IGNORE_TRAILING_BLANKS): This constructor initializes an OFoldStreambuf object and uses as its destination stream the std::ostream stream. The destructor writes any buffered information to the destination stream and will then flush the destination stream. MEMBER FUNCTIONS
All members of FBB::OFilterStreambuf, in particular its out() and open() members are available, as FBB::OFoldStreambuf inherits from this class. o void setMargins(size_t leftMargin, size_t rightMargin): This member can be used to modify the left- and right folding margins. Note that the left margin may also be modified using the FBB::lm and FBB::mlm manipulators. o void setTrailingBlanks(TrailingBlanks tb): This member can be used to modify the currently used TrailingBlanks parameter. o void useBlanks(): This member can be used to select blanks to be used when inserting left margins. o void useTabs(size_t tabWidth = 8): This member can be used to select tab-characters to be used when inserting left margins. The second parameter is used to specify the display width of a tab-character. STATIC MEMBER FUNCTIONS
o size_t leftMargin(std::ostreambuf const *buffer): This member returns the current left margin setting of the OFoldStreambuf object passed to it as its argument. The member defines a std::streambuf parameter which is down cast to an OFoldStreambuf and an FBB::Errno exception is thrown if that cast fails. o size_t rightMargin(std::ostreambuf const *buffer): This member returns the current right margin setting of the OFoldStreambuf object passed to it as its argument. The member's parame- ter is down cast in the same way as leftMargin()'s argument: an FBB::Errno exception is thrown if that cast fails. PROTECTED MEMBER FUNCTION
The member listed in this section implements the tasks of the comparably named virtual function in the class's private interface. This sep- arates the redefinable interface from the user-interface. The class OFoldStreambuf can, in accordance with Liskov's Substitution Principle, be used as a std:streambuf; but it also offers a facility for classes deriving from OFoldStreambuf. This facility is listed here. o int pSync(): The contents of the OFoldStreambuf's internal buffer is flushed. EXAMPLE
#include <iostream> #include <ostream> #include <string> #include <bobcat/ofoldstreambuf> using namespace std; using namespace FBB; int main() { OFoldStreambuf fb(cout, 4, 40); ostream out(&fb); out << lm(4); string line; while (getline(cin, line)) out << line << ' '; return 0; } FILES
bobcat/ofoldstreambuf - defines the class interface SEE ALSO
bobcat(7), lm(3bobcat), mlm(3bobcat), ofilterstreambuf(3bobcat), ofoldstream(3bobcat) BUGS
None Reported. DISTRIBUTION FILES
o bobcat_3.01.00-x.dsc: detached signature; o bobcat_3.01.00-x.tar.gz: source archive; o bobcat_3.01.00-x_i386.changes: change log; o libbobcat1_3.01.00-x_*.deb: debian package holding the libraries; o libbobcat1-dev_3.01.00-x_*.deb: debian package holding the libraries, headers and manual pages; o http://sourceforge.net/projects/bobcat: public archive location; BOBCAT
Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. COPYRIGHT
This is free software, distributed under the terms of the GNU General Public License (GPL). AUTHOR
Frank B. Brokken (f.b.brokken@rug.nl). libbobcat1-dev_3.01.00-x.tar.gz 2005-2012 FBB::OFoldStreambuf(3bobcat)
All times are GMT -4. The time now is 04:32 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy