Sponsored Content
Full Discussion: Nn$( expr $n + 1)
Top Forums Shell Programming and Scripting Nn$( expr $n + 1) Post 302945153 by Chubler_XL on Tuesday 26th of May 2015 04:18:33 PM
Old 05-26-2015
Some other alternatives:

Code:
let n=n+1
((n++))
((n=n+1))
n=$((n+1))

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

expr

Hello! I want to evaluate some mathematical expressions in a script and I try to use 'expr' command. Unfortunatally, when I have, for example, expr 8.2 + 6 the result is 'expr: non-numeric argument' Why ? I work on SunOs 5.7. Thanks in advance Nathe (5 Replies)
Discussion started by: Nathe
5 Replies

2. Shell Programming and Scripting

expr problem

Hi, in my ksh script expr 22 / 10 results as 2 but the actual result expected in 2.2. how do i get that result. Please help Thanks, (2 Replies)
Discussion started by: kotasateesh
2 Replies

3. Shell Programming and Scripting

getting error with expr

sum=0; cat op_api2 |while read word1 word2; do echo $word2 sum=`expr $word2 + $sum`; done echo $sum op_api2 ( file has this data ) ---------------------------- UsageSummary 1034 UsageSummary 1675 UnbilledUsage 175 UnbilledUsage 177 UnbilledUsage 177 UnbilledUsage 194 I want the... (2 Replies)
Discussion started by: bishweshwar
2 Replies

4. Red Hat

how to use expr

i am new to shell programming, currently using redhat linux of version 2.4.20-8. i have problem in executing expr command in the following shell script $ x=5 $ x='expr $x + 1' $ echo $x the output is displaying always expr $x + 1 Pls guide me for the above query (3 Replies)
Discussion started by: saikumarm80
3 Replies

5. Shell Programming and Scripting

test expr VS [ expr ]

What is the difference between test expr VS . For example : if test 5 -eq 6 echo "Wrong" and if echo "Wrong" bot will give the same output as Wrong. Now, what is the difference between these two? though they are producing the same result why we need two? Any answer will be... (2 Replies)
Discussion started by: ashok.g
2 Replies

6. Shell Programming and Scripting

expr command help

I'm trying to check if a variable'd string is only one character and use that in an if statement the only way I could find is: $expr "${var}" : . # expr STRING : regrep where the "." is the grep wildcard for any single character. Whats wrong with my code here and is there a... (3 Replies)
Discussion started by: Tewg
3 Replies

7. Shell Programming and Scripting

the expr \*

$ cat > mtable #!/bin/sh # #Script to test for loop # # if then echo "Error - Number missing form command line argument" echo "Syntax : $0 number" echo "Use to print multiplication table for given number" exit 1 fi n=$1 for i in 1 2 3 4 5 6 7 8 9 10 do echo "$n * $i = `expr $i \*... (1 Reply)
Discussion started by: jackel7777
1 Replies

8. UNIX for Dummies Questions & Answers

expr ?!

Hey there i want to subtract the content from $b from $a. Each variable has got 18 values (normal numbers from 0 - 99). How can i subtract them? I know i have to use the expr command, this is what i have till now: a=`cat Tabelle.dat | awk {'print $4'} | awk -F: {'print $1'}` b=`cat... (1 Reply)
Discussion started by: Mad van Bert
1 Replies

9. Shell Programming and Scripting

Error with expr - "expr: syntax error"

Hi All, I'm writing a shell script in KSH, where I want to store the filename, total record count and actual record count of all the source files. The source files reside in 4 different sub-folders under the same root folder. Below is code: #!/usr/bin/ksh... (6 Replies)
Discussion started by: jagari
6 Replies

10. Shell Programming and Scripting

If + expr

Hi I have bellow script: t1=`cat node1.txt | grep thread1 | cut -f2 -d '-'` t2=`cat node2.txt | grep thread2 | cut -f2 -d '-'` t3=`cat node1_rcat.txt | grep thread1 | cut -f2 -d '-'` t4=`cat node2_rcat.txt | grep thread2 | cut -f2 -d '-'` if ]; then echo "no restore" >> log.log... (6 Replies)
Discussion started by: primo102
6 Replies
update-alternatives(8)						update-alternatives					    update-alternatives(8)

NAME
update-alternatives - maintain symbolic links determining default commands SYNOPSIS
update-alternatives [options] command DESCRIPTION
update-alternatives creates, removes, maintains and displays information about the symbolic links comprising the SUSE alternatives system. It is possible for several programs fulfilling the same or similar functions to be installed on a single system at the same time. For example, many systems have several text editors installed at once. This gives choice to the users of a system, allowing each to use a dif- ferent editor, if desired, but makes it difficult for a program to make a good choice for an editor to invoke if the user has not specified a particular preference. SUSE's alternatives system aims to solve this problem. A generic name in the filesystem is shared by all files providing interchangeable functionality. The alternatives system and the system administrator together determine which actual file is referenced by this generic name. For example, if the text editors ed(1) and nvi(1) are both installed on the system, the alternatives system will cause the generic name /usr/bin/editor to refer to /usr/bin/nvi by default. The system administrator can override this and cause it to refer to /usr/bin/ed instead, and the alternatives system will not alter this setting until explicitly requested to do so. The generic name is not a direct symbolic link to the selected alternative. Instead, it is a symbolic link to a name in the alternatives directory, which in turn is a symbolic link to the actual file referenced. This is done so that the system administrator's changes can be confined within the /etc directory: the FHS (q.v.) gives reasons why this is a Good Thing. When each package providing a file with a particular functionality is installed, changed or removed, update-alternatives is called to update information about that file in the alternatives system. update-alternatives is usually called from the postin/postun or preun scripts in rpm packages. It is often useful for a number of alternatives to be synchronised, so that they are changed as a group; for example, when several versions of the vi(1) editor are installed, the man page referenced by /usr/share/man/man1/vi.1 should correspond to the executable referenced by /usr/bin/vi. update-alternatives handles this by means of master and slave links; when the master is changed, any associated slaves are changed too. A master link and its associated slaves make up a link group. Each link group is, at any given time, in one of two modes: automatic or manual. When a group is in automatic mode, the alternatives sys- tem will automatically decide, as packages are installed and removed, whether and how to update the links. In manual mode, the alterna- tives system will not change the links; it will leave all the decisions to the system administrator. Link groups are in automatic mode when they are first introduced to the system. If the system administrator makes changes to the system's automatic settings, this will be noticed the next time update-alternatives is run on the changed link's group, and the group will automati- cally be switched to manual mode. Each alternative has a priority associated with it. When a link group is in automatic mode, the alternatives pointed to by members of the group will be those which have the highest priority. When using the --config option, update-alternatives will list all of the choices for the link group of which given name is the master link. The current choice is marked with a '*' and the choice with the highest priority with a '+'. You will then be prompted for your choice regarding this link group. Once you make a change, the link group will no longer be in auto mode. You will need to use the --auto option in order to return to the automatic mode. If you want to configure non-interactively you can use the --set option instead (see below). Different packages providing the same file need to do so cooperatively. That is - the usage of update-alternatives is mandatory for all involved packages in such case - it is not possible to override some file in a package that does not employ the update-alternatives mecha- nism. TERMINOLOGY
Since the activities of update-alternatives are quite involved, some specific terms will help to explain its operation. generic name A name, like /usr/bin/editor, which refers, via the alternatives system, to one of a number of files of similar function. symlink Without any further qualification, this means a symbolic link in the alternatives directory: one which the system administrator is expected to adjust. alternative The name of a specific file in the filesystem, which may be made accessible via a generic name using the alternatives system. alternatives directory A directory, by default /etc/alternatives, containing the symlinks. administrative directory A directory, by default /var/lib/rpm/alternatives, containing update-alternatives' state information. link group A set of related symlinks, intended to be updated as a group. master link The link in a link group which determines how the other links in the group are configured. slave link A link in a link group which is controlled by the setting of the master link. automatic mode When a link group is in automatic mode, the alternatives system ensures that the links in the group point to the highest priority alternative appropriate for the group. manual mode When a link group is in manual mode, the alternatives system will not make any changes to the system administrator's settings. COMMANDS
--install genname symlink altern priority [--slave genname symlink altern]... Add a group of alternatives to the system. genname is the generic name for the master link, symlink is the name of its symlink in the alternatives directory, and altern is the alternative being introduced for the master link. The arguments after --slave are the generic name, symlink name in the alternatives directory and the alternative for a slave link. Zero or more --slave options, each followed by three arguments, may be specified. If the master symlink specified exists already in the alternatives system's records, the information supplied will be added as a new set of alternatives for the group. Otherwise, a new group, set to automatic mode, will be added with this information. If the group is in automatic mode, and the newly added alternatives' priority is higher than any other installed alternatives for this group, the symlinks will be updated to point to the newly added alternatives. --set name path Set the program path as alternative for name. This is equivalent to --config but is non-interactive and thus scriptable. --remove name path Remove an alternative and all of its associated slave links. name is a name in the alternatives directory, and path is an absolute filename to which name could be linked. If name is indeed linked to path, name will be updated to point to another appropriate alternative, or removed if there is no such alternative left. Associated slave links will be updated or removed, correspondingly. If the link is not currently pointing to path, no links are changed; only the information about the alternative is removed. --remove-all name Remove all alternatives and all of their associated slave links. name is a name in the alternatives directory. --all Call --config on all alternatives. --auto link Switch the master symlink link to automatic mode. In the process, this symlink and its slaves are updated to point to the highest priority installed alternatives. --display link Display information about the link group of which link is the master link. Information displayed includes the group's mode (auto or manual), which alternative the symlink currently points to, what other alternatives are available (and their corresponding slave alternatives), and the highest priority alternative currently installed. --list link Display all targets of the link group. --config link Show available alternatives for a link group and allow the user to interactively select which one to use. The link group is updated and taken out of auto mode. --help Show the usage message and exit. --version Show the version and exit. OPTIONS
--altdir directory Specifies the alternatives directory, when this is to be different from the default. --admindir directory Specifies the administrative directory, when this is to be different from the default. --verbose Generate more comments about what update-alternatives is doing. --quiet Don't generate any comments unless errors occur. This option is not yet implemented. FILES
/etc/alternatives/ The default alternatives directory. Can be overridden by the --altdir option. /var/lib/rpm/alternatives/ The default administration directory. Can be overridden by the --admindir option. EXIT STATUS
0 The requested action was successfully performed. 2 Problems were encountered whilst parsing the command line or performing the action. DIAGNOSTICS
update-alternatives chatters incessantly about its activities on its standard output channel. If problems occur, update-alternatives out- puts error messages on its standard error channel and returns an exit status of 2. These diagnostics should be self-explanatory; if you do not find them so, please report this as a bug. EXAMPLES
There are several packages which provide a text editor compatible with vi, for example nvi and vim. Which one is used is controlled by the link group vi, which includes links for the program itself and the associated manpage. To display the available packages which provide vi and the current setting for it, use the --display action: update-alternatives --display vi To choose a particular vi implementation, use this command as root and then select a number from the list: update-alternatives --config vi To go back to having the vi implementation chosen automatically, do this as root: update-alternatives --auto vi BUGS
If you find a bug, please report it using the bugzilla.novell.com, or, if that is not possible, email the author directly. If you find any discrepancy between the operation of update-alternatives and this manual page, it is a bug, either in the implementation or the documentation; please report it. AUTHOR
Copyright (C) 1995 Ian Jackson This is free software; see the GNU General Public Licence version 2 or later for copying conditions. There is NO WARRANTY. This manual page is copyright 1997,1998 Charles Briscoe-Smith. This is free documentation; see the GNU General Public Licence version 2 or later for copying conditions. There is NO WARRANTY. SEE ALSO
ln(1), FHS, the Filesystem Hierarchy Standard. SUSE
2007-07-18 update-alternatives(8)
All times are GMT -4. The time now is 10:39 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy