Sponsored Content
Top Forums Shell Programming and Scripting Bash 101 - to (do) ; or not to (do) ; ? Post 303022252 by bakunin on Tuesday 28th of August 2018 05:18:15 PM
Old 08-28-2018
Quote:
Originally Posted by annacreek
Code:
while [ $i -lt 4 ] do xterm & i=$[$i+1] done

I don't know from which "manual" you got that, but there are more errors then correct words in it. Shame on whoever wrote this drivel. The correct form would be:

Code:
while [ $i -lt 4 ] ; do xterm & ; (( i = i+1 )) ; done

or, in a more readable way:

Code:
while [ $i -lt 4 ] ; do
     xterm &
     (( i = i+1 ))
done

Note that [ is actually a real command: it is a different way to invoke /bin/test. Written in "long form" where the command is more easily recognisable it would be:

Code:
while /bin/test $i -lt 4 ; do
     xterm &
     (( i = i+1 ))
done

The command

Code:
/bin/test $i -lt 4

will return 0 (logical TRUE) if the variable i is lower than 4 and 1 (logically FALSE) otherwise. The while-loop is repeated as long as the control-command (in this case /bin/test) returns 0 and stops if it returns 1. The following will read a complete file:

Code:
while read LINE ; do
     echo "== $LINE =="
done < /some/file

because the read-command returns 0 as long as it can read a line but returns 1 when it hits end-of-file.

I hope this helps.

bakunin
 

3 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Daemon 101

I think I have an issue almost like Sammy_T's. I want to make a piece of code run as a daemon. I have some java, along with it 15 classpath's converted to a shell script that I can "runmyjavap". The script is just what I need to run after compiling it: #!/bin/sh java -classpath : ...(from... (3 Replies)
Discussion started by: Miller_K
3 Replies

2. UNIX for Dummies Questions & Answers

Help Me please scripting 101

Hi, I had to pull a handful of account numbers from a file into a table. Now I want to do a basic list from a directory in my program showing me if any files for these customers exist. There are files associated with each client and need to be processed individually. $Paytos = 00153301 00153302... (5 Replies)
Discussion started by: ski
5 Replies

3. Shell Programming and Scripting

Bash 101 - string assigment

I am embarrassed to ask this but I am at the end of my rope. I am trying to assign one (string) variable to another. I do understand that bash variables are "not typed", but still learning usage of {} and spaces in script. I was hoping this syntax would work $variableA =... (6 Replies)
Discussion started by: annacreek
6 Replies
resize(1X)																resize(1X)

NAME
resize - set TERMCAP and terminal settings to current xterm window size SYNOPSIS
resize [-u] [-c] [-s[row col]] OPTIONS
The following options may be used with resize: This option indicates that Bourne shell commands should be generated even if the user's cur- rent shell is not /bin/sh. This option indicates that C shell commands should be generated even if the user's current shell is not /bin/csh. This option indicates that Sun console escape sequences will be used instead of the special xterm escape code. If rows and col- umns are given, resize will ask the xterm to resize itself. However, the window manager may choose to disallow the change. DESCRIPTION
The resize command prints a shell command for setting the TERM and TERMCAP environment variables to indicate the current size of xterm win- dow from which the command is run. For this output to take effect, resize must either be evaluated as part of the command line (usually done with a shell alias or function) or else redirected to a file which can then be read in. From the C shell (usually known as /bin/csh), the following alias could be defined in the user's % alias rs 'set noglob; eval `resize`' After resizing the window, the user would type: % rs Users of versions of the Bourne shell (usually known as /bin/sh) that do not have command functions will need to send the output to a tem- porary file and the read it back in with the "." command: $ resize > /tmp/out $ . /tmp/out FILES
for the base termcap entry to modify. user's alias for the command. BUGS
The -u or -c must appear to the left of -s if both are specified. SEE ALSO
csh(1), tset(1), xterm(1X) AUTHORS
Mark Vandevoorde (MIT-Athena), Edward Moy (Berkeley) Copyright (c) 1984, 1985 by X Consortium See X(1X) for a complete copyright notice. resize(1X)
All times are GMT -4. The time now is 01:29 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy