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
COMMAND-NOT-FOUND(1)					    http://en.opensuse.org/Sco					      COMMAND-NOT-FOUND(1)

NAME
command-not-found - A command-not-found handler SYNOPSIS
command-not-found {binary_name} {repository} ARGUMENTS
The following arguments are required: binary_name The name of binary you are looking for. repository The name of repository for search. For most cases, use zypp DESCRIPTION
command-not-found handler is designed to tell users which package contains a missing command. The handler is integrated to bash(1) and zsh(1) shells and is not necessary to call it directly. Just type a name of the command in your favourite shell and you'll get a result. If you consider c-n-f handler useless, just add unset command_not_found_handle to your profile or remove the command-not-found package. Handler doesn't call the command-not-found binary directly, it only prints info about it. If you want to invoke it automatically, just add export COMMAND_NOT_FOUND_AUTO=1 to your bash profile. EXAMPLE
: NORMAL USAGE For example you want to try blender, because you have heard that is an amazing program. So just type blender in shell: $ blender You get the following output: The program 'blender' can be found in the following package: * blender [ path: /usr/bin/blender, repository: zypp (openSUSE 11.1-0) ] Try installing with: sudo zypper install blender bash: blender: command not found SEE ALSO
scout(1) AUTHOR
Pavol Rusnak <stick@gk2.sk> Developer http://gitorious.org/opensus 08/07/2009 COMMAND-NOT-FOUND(1)
All times are GMT -4. The time now is 10:38 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy