Sponsored Content
Full Discussion: Incrementing number in bash
Top Forums Shell Programming and Scripting Incrementing number in bash Post 302609631 by kristinu on Tuesday 20th of March 2012 08:49:52 AM
Old 03-20-2012
Incrementing number in bash

I have the following code and getting the error
Code:
./raytrac.bash: line 231: ((: 0++: syntax error: operand expected (error token is "+")
iarg = 0

Code:
       iarg=0
       narg=$#                   # Number of arguments passed.
       echo "narg = $narg"
       argsArr=("$@")            # Set array containing all arguments.
       while (($iarg < $narg))
       do
         echo "iarg = $iarg"
         arg=${argsArr[$iarg]}   # Bash arrays are zero-based: first element is indexed at 0.
         (($iarg++))
       done

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

bash: testing if string is a number

How do you test if a string is a number? Trying to do something like this: x="AS" if( x is not a number ); then x=0 fi Because I want to do number arithmetic with x. (3 Replies)
Discussion started by: eur0dad
3 Replies

2. Shell Programming and Scripting

perl + array and incrementing number

morning guys and gals, I am haveing a problem, a friend helped me out with this script but i dont know how to add incrementing number for each movie in movie.list. this is what i have so far. any assistance would be great. I have removed the GT and LT symbols so you can see what is going on... (5 Replies)
Discussion started by: Optimus_P
5 Replies

3. Shell Programming and Scripting

Number/string format in bash

I would like to change the format of an integer type number adding zeros to the left of it in a script in bash. For example number=1 echo $number 00001 Thanks (3 Replies)
Discussion started by: josegr
3 Replies

4. Shell Programming and Scripting

how to format a number in bash

Say I have a number x=123, but I want to it be x=000123, because I need to use it in as a file name. thanks! (2 Replies)
Discussion started by: aerosols
2 Replies

5. Shell Programming and Scripting

changing number in bash (number is in form of string)

I have a txt file as database. when i run my program what it does is it ask me for 3 name and stored in the file as name1:name2:name3:1 when u enter 3 name it add those in file as above format and add 1 at the end. I what i want is if i enter same names again it changes that 1 to 2 and so... (3 Replies)
Discussion started by: Learnerabc
3 Replies

6. UNIX for Dummies Questions & Answers

Incrementing the New File Version Number

Hello All, In the below script i am trying to check and list the file names, get the last file with highest version number and then increment the version number when i create another file. Example: file1 is COBANK_v1.xml and file2 i want to put it as COBANK_v2.xml, to achieve this i am using awk... (15 Replies)
Discussion started by: Ariean
15 Replies

7. Shell Programming and Scripting

Replacing string by incrementing number

Dear all Say I have a file as ! TICKET NBR : 234 !GSI : 102 ! 3100.2.112.1 11/06/2013 15:56:29 ! 3100.2.22.3 98 ! 3100.2.134.2 8 ! ! TICKET NBR : 1809 ! GSI : 102 ! 3100.2.112.1 11/06/2013 16:00:45 ! 3100.2.22.3 65 ! 3100.2.134.2 3 ! ! TICKET NBR : 587 ! GSI : 102 ! 3100.2.112.1... (3 Replies)
Discussion started by: OTNA
3 Replies

8. Shell Programming and Scripting

Incrementing parts of ten digits number by parts

I have number in file which contains date and serial number: 2013101000. The last two digits are serial number (00). So maximum of serial number is 100. After reaching 100 it becomes 00 with incrementing 10 which is day with max 31. after reaching 31 it becomes 00 and increments 10... (31 Replies)
Discussion started by: Natalie
31 Replies

9. UNIX for Beginners Questions & Answers

Incrementing the New File Version Number

Hi, This is my first post here. I am using cygwin on Windows 7. I am starting with a data file with filename "name_1.ext", like "20180831_snapgenotypes_1.csv". The "_1" before ".ext" is a version number. Integers (0-99) are sufficient. They don't have to be like "1.0.0". The filename may... (2 Replies)
Discussion started by: minimalist
2 Replies

10. UNIX for Beginners Questions & Answers

UNIX replacing and incrementing number

Hi I am unix newbie looking for a unix bash script that can make it easier to do my code work. we have a code number for each code block that we want to incrementally assign. We have 10000 of these and it is very laborious to do this one by one. so what we want is start from the top of the... (4 Replies)
Discussion started by: chamajid
4 Replies
PERFMONCTL(2)						     Linux Programmer's Manual						     PERFMONCTL(2)

NAME
perfmonctl - interface to IA-64 performance monitoring unit SYNOPSIS
#include <syscall.h> #include <perfmon.h> long perfmonctl(int fd, int cmd, void *arg, int narg); Note: There is no glibc wrapper for this system call; see NOTES. DESCRIPTION
The IA-64-specific perfmonctl() system call provides an interface to the PMU (performance monitoring unit). The PMU consists of PMD (per- formance monitoring data) registers and PMC (performance monitoring control) registers, which gather hardware statistics. perfmonctl() applies the operation cmd to the input arguments specified by arg. The number of arguments is defined by narg. The fd argu- ment specifies the perfmon context to operate on. Supported values for cmd are: PFM_CREATE_CONTEXT perfmonctl(int fd, PFM_CREATE_CONTEXT, pfarg_context_t *ctxt, 1); Set up a context. The fd parameter is ignored. A new perfmon context is created as specified in ctxt and its file descriptor is returned in ctxt->ctx_fd. The file descriptor can be used in subsequent calls to perfmonctl() and can be used to read event notifications (type pfm_msg_t) using read(2). The file descriptor is pollable using select(2), poll(2), and epoll(7). The context can be destroyed by calling close(2) on the file descriptor. PFM_WRITE_PMCS perfmonctl(int fd, PFM_WRITE_PMCS, pfarg_reg_t *pmcs, n); Set PMC registers. PFM_WRITE_PMDS perfmonctl(int fd, PFM_WRITE_PMDS, pfarg_reg_t *pmds, n); Set PMD registers. PFM_READ_PMDS perfmonctl(int fd, PFM_READ_PMDS, pfarg_reg_t *pmds, n); Read PMD registers. PFM_START perfmonctl(int fd, PFM_START, NULL, 0); Start monitoring. PFM_STOP perfmonctl(int fd, PFM_STOP, NULL, 0); Stop monitoring. PFM_LOAD_CONTEXT perfmonctl(int fd, PFM_LOAD_CONTEXT, pfarg_load_t *largs, 1); Attach the context to a thread. PFM_UNLOAD_CONTEXT perfmonctl(int fd, PFM_UNLOAD_CONTEXT, NULL, 0); Detach the context from a thread. PFM_RESTART perfmonctl(int fd, PFM_RESTART, NULL, 0); Restart monitoring after receiving an overflow notification. PFM_GET_FEATURES perfmonctl(int fd, PFM_GET_FEATURES, pfarg_features_t *arg, 1); PFM_DEBUG perfmonctl(int fd, PFM_DEBUG, val, 0); If val is nonzero, enable debugging mode, otherwise disable. PFM_GET_PMC_RESET_VAL perfmonctl(int fd, PFM_GET_PMC_RESET_VAL, pfarg_reg_t *req, n); Reset PMC registers to default values. RETURN VALUE
perfmonctl() returns zero when the operation is successful. On error, -1 is returned and errno is set to indicate the cause of the error. VERSIONS
perfmonctl() is available since Linux 2.4. CONFORMING TO
perfmonctl() is Linux-specific and is available only on the IA-64 architecture. NOTES
Glibc does not provide a wrapper for this system call; call it using syscall(2). SEE ALSO
gprof(1) The perfmon2 interface specification COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2017-09-15 PERFMONCTL(2)
All times are GMT -4. The time now is 11:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy