Sponsored Content
Full Discussion: If loop query
Top Forums UNIX for Beginners Questions & Answers If loop query Post 302994526 by itkamaraj on Friday 24th of March 2017 03:09:59 AM
Old 03-24-2017
If is not loop. Its conditional statement.

I guess, APPEND is having string.

please try this

Code:
#!/bin/bash

echo -n "Enter the String : "
read APPEND
LENGTH=${#APPEND}
if [[ -z "${APPEND}" || $((LENGTH+1))%3 -eq "0" ]]
then
      echo "print $APPEND"
fi

This User Gave Thanks to itkamaraj For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Simple loop query

Hi All Just started with shell scripts and am stumped by, what is to most of you no doubt, a simple issue. All I'm trying to do is prompt a user for input and writing to a log file. If the user types the word 'stop', then the program should halt. If the word typed is 'clear', then the log file... (2 Replies)
Discussion started by: kutz13
2 Replies

2. Shell Programming and Scripting

Dynamic update loop query on Sybase database

Hello Guys, I'm new to Shell scripting, and i need someone to help me with this issue: I'm trying to do a dynamic update query on Sysbase database table using shell script. Lets say, the Update query is "update Table set id=X" , where X is dynamic value for the loop index. If the loop is... (10 Replies)
Discussion started by: Alaeddin
10 Replies

3. Shell Programming and Scripting

Query regarding for loop.

Filename.txt My First Line My Second Line ::::While Loop::: Program: while read line do echo "$line" done < Filename.txt output: My First Line My Second Line Is it possible to use for loop to get the same output. I have tried executing below code but i get every word of my file... (8 Replies)
Discussion started by: pinga123
8 Replies

4. Shell Programming and Scripting

SQL query in a loop with single sqlplus connection

Hi, I'm trying to build a shell script that reads a set of accounts from a file. For each account I need to perform a set of sql queries. So I have a loop with a set of sqlplus connections to retrieved my data. Is it possible to have a single sqlplus connection before entering the loop and... (4 Replies)
Discussion started by: lsantacana
4 Replies

5. Shell Programming and Scripting

Need help to run query in loop for all acct nbr in a file..

I have a txt file with contents of acct nbr's like: 22222222222 33333333333 33445566778 I need to write a script which takes each acct nbr in the file and run the query like: select seq_nbr from event where acct_nbr='22222222222' and the query's output should be passed to a... (0 Replies)
Discussion started by: Rajesh Putnala
0 Replies

6. Shell Programming and Scripting

Need help to run query in loop for all acct nbr in a file..

I have a txt file with contents of acct nbr's like: 22222222222 33333333333 33445566778 I need to write a script which takes each acct nbr in the file and run the query like: select seq_nbr from event where acct_nbr='22222222222' and the query's output should be passed to a... (2 Replies)
Discussion started by: Rajesh Putnala
2 Replies

7. Shell Programming and Scripting

Query regarding the if loop

Hi friends, One of my shell program(test.ksh) contains the following if loop.Can anyone please explain me how this loop will work The shell script will be executed as test.ksh -d all The value of variables are user=all opt=-d if && then && _del_all_w=1 || _group="${1}"... (1 Reply)
Discussion started by: kavithakuttyk
1 Replies

8. Shell Programming and Scripting

awk loop - substr and sub query

Hi there Looking for help with formating text output. I have following file 1ABC1234567890123Y 31-Jul-2012 1DEF1234567890124NMEDIUM 31-Jul-2012 193939312345889 YSMALL 31-Jul-2012 10093939312345889YSMALL 31-Jul-2012 1 YSMALL 31-Jul-2012 ... (14 Replies)
Discussion started by: viallos
14 Replies

9. Shell Programming and Scripting

Infinite loop query

I have a script script.shwhich is scheduled to run at 11 AM everyday. # script.sh Code: ./scb_script.sh & unfortunately scb_script.sh is running today in infinite loop as respective files are not available. My question, when script.sh starts running tomorrow, will the old process be... (1 Reply)
Discussion started by: JSKOBS
1 Replies

10. Shell Programming and Scripting

For loop query...

Hi all... I am using a for loop for another part of AudioScope... Consider this code:- for n in {0..100} do if }" = "another_string" ] then break fi done This works perfectly except I am not sure if breaking out of a 'for' loop might cause... (2 Replies)
Discussion started by: wisecracker
2 Replies
foreach(n)						       Tcl Built-In Commands							foreach(n)

__________________________________________________________________________________________________________________________________________________

NAME
foreach - Iterate over all elements in one or more lists SYNOPSIS
foreach varname list body foreach varlist1 list1 ?varlist2 list2 ...? body _________________________________________________________________ DESCRIPTION
The foreach command implements a loop where the loop variable(s) take on values from one or more lists. In the simplest case there is one loop variable, varname, and one list, list, that is a list of values to assign to varname. The body argument is a Tcl script. For each element of list (in order from first to last), foreach assigns the contents of the element to varname as if the lindex command had been used to extract the element, then calls the Tcl interpreter to execute body. In the general case there can be more than one value list (e.g., list1 and list2), and each value list can be associated with a list of loop variables (e.g., varlist1 and varlist2). During each iteration of the loop the variables of each varlist are assigned consecutive values from the corresponding list. Values in each list are used in order from first to last, and each value is used exactly once. The total number of loop iterations is large enough to use up all the values from all the value lists. If a value list does not contain enough elements for each of its loop variables in each iteration, empty values are used for the missing elements. The break and continue statements may be invoked inside body, with the same effect as in the for command. Foreach returns an empty string. EXAMPLES
The following loop uses i and j as loop variables to iterate over pairs of elements of a single list. set x {} foreach {i j} {a b c d e f} { lappend x $j $i } # The value of x is "b a d c f e" # There are 3 iterations of the loop. The next loop uses i and j to iterate over two lists in parallel. set x {} foreach i {a b c} j {d e f g} { lappend x $i $j } # The value of x is "a d b e c f {} g" # There are 4 iterations of the loop. The two forms are combined in the following example. set x {} foreach i {a b c} {j k} {d e f g} { lappend x $i $j $k } # The value of x is "a d e b f g c {} {}" # There are 3 iterations of the loop. SEE ALSO
for(n), while(n), break(n), continue(n) KEYWORDS
foreach, iteration, list, looping Tcl foreach(n)
All times are GMT -4. The time now is 12:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy