Sponsored Content
Top Forums Shell Programming and Scripting 'Combining 2 while loops together' Post 302282060 by Firestarter on Friday 30th of January 2009 05:10:18 AM
Old 01-30-2009
Quote:
Originally Posted by Corona688
What should it do if its a number or word? That affects how one might check and where.

Also, why do you do this:
Code:
read Something in

That tries to read into two variables, 'Something' and 'in', but 'in' never gets used. You can leave it off, the statement will work without it.

Also, please use code tags for code. Quote my post to see how.
Sorry, I'm new to this forum. Will use the code tag in future.

The input should be a word, not a number. If the input is a number, it will keep looping and echoing an invalid statement until the input is a word.
The problem I am facing is, the first loop is working, I cannot input a blank, but I can still input numbers.

I am thinking of something like this
Code:
read Name
while [ -z "${Name}" |`echo $Name | grep  "[^A-Z]"`]
do
echo "You cannot input a blank or numeric name."
read Name
done

Yes, and I realised that the 'in' does not affect anything. Will remove it.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

no more loops

Hello Guys I need some help with my script I'm not very good at this, hope you can point me in the right direction. My idea, to write a file with some router commands and use it on a script for me to run on a demand basis, ( or added to the cron, if I get it to work). The below script works,... (5 Replies)
Discussion started by: tony3101
5 Replies

2. Shell Programming and Scripting

Loops within loops

I am running on HPUX using ksh. I have a script that uses a loop within a loop, for some reason the script seems to hang on a particuliar record. The record is fine and hits the condition in Blue. If I kill the 1st loop process the script continues on with no problem. Begin code> <Some... (8 Replies)
Discussion started by: bthomas
8 Replies

3. UNIX for Dummies Questions & Answers

While Loops

I'm trying to create a loop that will prompt the user for 15 values, not forcing them to enter all 15. If the user enters through one or more of the prompts the null value needs to be converted to 0, otherwise set the parameter = to the value entered: ex. Please enter file no #1: 17920 ... (4 Replies)
Discussion started by: vdc
4 Replies

4. UNIX for Dummies Questions & Answers

two loops

Hi, how can I use "for" to have two loops : this is my script : for i in (A B C) do for j in (a b c) do echo $i$j done done #End I want to print out Aa Ab Ac .... But I have error message : syntax error at line 1 : `(' unexpected Many thanks before. How should I use "for" ?? (2 Replies)
Discussion started by: big123456
2 Replies

5. UNIX for Dummies Questions & Answers

Help with While Loops

I am traversing down a list, and I am not quite sure how to tell the loop to break when it's done going through the file. #!/bin/sh while : do read list <&3 echo $list done is the code. The file "list" is simply 5 4 3 2 1 any advice on how to break the loop after the file is... (1 Reply)
Discussion started by: MaestroRage
1 Replies

6. Shell Programming and Scripting

Loops

Hi All, I want to execute a script the number of times a user enters. Please can you advise on hor can I do the same. Many Thanks, Shazin (4 Replies)
Discussion started by: Shazin
4 Replies

7. Shell Programming and Scripting

loops

Hi All I have some directories on our server which are containing .csv files. i need to print value of cell "B2" from those csv files. Please advise. I have tried head command as example: head -2 */Book_Collection_Report_1_-_Collection_Requests_trials.csv | sed -n "3p" | awk -F","... (4 Replies)
Discussion started by: yash1978
4 Replies

8. Shell Programming and Scripting

Two Loops

Hi please help. I have a file with two columns. I want to insert the value of the first column and second column in different sections of a line. code: for line in `cat $1`; for x in `cat $1 |awk '{print $2}'`; do do echo "print $line and then print $x" done done It works... (8 Replies)
Discussion started by: cinderella
8 Replies

9. Shell Programming and Scripting

Too many for loops

My apologies for the long post.... I have a structure problem with my ksh script on linux. right now it does what i want (which i know is the point) but its really really ugly and i know there must be a simpler way to achieve my task. The data is a list of usernames. This list will help... (2 Replies)
Discussion started by: maverick72
2 Replies

10. UNIX for Advanced & Expert Users

Help with loops?

I'm trying to understand better the while and until loops, can someone help me with this example? #!/bin/bash # Listing the planets. for planet in Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune Pluto do echo $planet # Each planet on a separate line. done echo; echo for... (3 Replies)
Discussion started by: jose2802
3 Replies
SETCAP(8)                                                     System Manager's Manual                                                    SETCAP(8)

NAME
setcap - set file capabilities SYNOPSIS
setcap [-q] [-v] (capabilities|-|-r) filename [ ... capabilitiesN fileN ] DESCRIPTION
In the absence of the -v (verify) option setcap sets the capabilities of each specified filename to the capabilities specified. The -v option is used to verify that the specified capabilities are currently associated with the file. The capabilities are specified in the form described in cap_from_text(3). The special capability string, '-', can be used to indicate that capabilities are read from the standard input. In such cases, the capabil- ity set is terminated with a blank line. The special capability string, '-r', is used to remove a capability set from a file. The -q flag is used to make the program less verbose in its output. EXIT CODE
The setcap program will exit with a 0 exit code if successful. On failure, the exit code is 1. SEE ALSO
cap_from_text(3), cap_set_file(3), getcap(8) 24th October 2008 SETCAP(8)
All times are GMT -4. The time now is 07:36 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy