Sponsored Content
Top Forums Shell Programming and Scripting Need Help with function that has multiple ranges Post 302521532 by ctsgnb on Wednesday 11th of May 2011 01:30:33 PM
Old 05-11-2011
Isn't it what the seq command does ? (just as demonstrated above)

Try to enter these commands :
Code:
seq 0 10
seq 5 10
seq 1 100

Or could you please provide a full example of what input and output you expect (just as i did) so it may help us to understand your needs and provide a more accurante answer to you.
Thanks
 

10 More Discussions You Might Find Interesting

1. Programming

returning multiple values from a function in C

hi how can I return multiple values from a C function. I tried the following: #include <stdio.h> void foo(int id, char *first_name, char *last_name) { /* this is just an example to illustrate my problem... real code makes use of the "id" parameter. */ first_name = (char... (8 Replies)
Discussion started by: Andrewkl
8 Replies

2. Shell Programming and Scripting

How to achieve Parellelism for the function which has multiple cp commands

Hi, Here is my requirement. Currently, there is a function which gets called in a for loop 2 times. doCopy() { cp /src/a*.jar /target/ cp /src/b*.jar /target/ cp /src/c*.jar /target } Since it is called sequentially from the for loop, I was asked to make parellel copy to... (7 Replies)
Discussion started by: kgsrinivas
7 Replies

3. Programming

Passing multiple values from a function in C

I know multiple values can be returned from a function in C like this: char **read_file ( char * , unsigned long int * );//this is the function prototypeunsigned long int number_of_words = 0;//variable defined in main() and initialized to 0words_from_dictionary = read_file ( "dictionary.dit" ,... (2 Replies)
Discussion started by: shoaibjameel123
2 Replies

4. Shell Programming and Scripting

extracting columns falling within specific ranges for multiple files

Hi, I need to create weekly files from daily records stored in individual monthly filenames from 1999-2010. my sample file structure is like the ones below: daily record stored per month: 199901.xyz, 199902.xyz, 199903.xyz, 199904.xyz ...199912.xyz records inside 199901.xyz (original data... (4 Replies)
Discussion started by: ida1215
4 Replies

5. Shell Programming and Scripting

How to convert multiple number ranges into sequence?

Looking for a simple way to convert ranges to a numerical sequence that would assign the original value of the range to the individual numbers that are on the range. Thank you given data 13196-13199 0 13200 4 13201 10 13202-13207 3 13208-13210 7 desired... (3 Replies)
Discussion started by: jcue25
3 Replies

6. Shell Programming and Scripting

Returning and capturing multiple return values from a function

Hi I am pretty confused in returning and capturing multiple values i have defined a function which should return values "total, difference" i have used as #!/usr/bin/ksh calc() { total=$1+$2 echo "$total" diff=$2-$1 echo "$diff" } I have invoked this function as calc 5 8 Now i... (2 Replies)
Discussion started by: Priya Amaresh
2 Replies

7. Shell Programming and Scripting

Using multiple gsub() function under a loop in awk

Hi ALL, I want to replace string occurrence in my file "Config" using a external file named "Mapping" using awk. $cat Config ! Configuration file for RAVI ! Configuration file for RACHANA ! Configuration file for BALLU $cat Mapping ravi:ram rachana:shyam ballu:hameed The... (5 Replies)
Discussion started by: useless79
5 Replies

8. Shell Programming and Scripting

Sum values of specific column in multiple files, considering ranges defined in another file

I have a file (let say file B) like this: File B: A1 3 5 A1 7 9 A2 2 5 A3 1 3 The first column defines a filename and the other two define a range in that specific file. In the same directory, I have also three more files (File A1, A2 and A3). Here is 10 sample lines... (3 Replies)
Discussion started by: Bastami
3 Replies

9. Shell Programming and Scripting

[bash] wanted: function with a clean way for multiple return values

Hi, I have a small part of a project which is done as a bash script. bash was selected as an portability issue that works out of the box. In this script I have an exec shell-function, a wrapper around arbitrary commands. I want to have STDOUT, as an addon STDERR and the EXIT-CODE of a specified... (5 Replies)
Discussion started by: stomp
5 Replies

10. Shell Programming and Scripting

How to call Oracle function with multiple arguments from shell script?

Dear All, I want to know how can i call oracle function from shell script code . My oracle function have around 5 input parameters and one return value. for name in *.csv; do echo "connecting to DB and start processing '$name' file at " echo "csv file name=$x" sqlplus -s scoot/tiger <!... (2 Replies)
Discussion started by: Balraj
2 Replies
profil(2)							System Calls Manual							 profil(2)

NAME
profil - Starts and stops execution profiling SYNOPSIS
void profil( unsigned short *short_buffer, unsigned int buffer_size, void *offset, unsigned int scale ); #include <sys/resource.h> void profil( struct profil_args *args, int buffer_size, -1, unsigned long flags); PARAMETERS
Points to an area of memory in the user address space. Its length (in bytes) is given by the buffer_size parameter. Specifies the length (in bytes) of the buffer. When offset is -1, indicating that the extended profil format shown in the second synopsis above is in use, the buffer_size parameter indicates the number of profil_args structures in the args array. Specifies the delta of program counter start and buffer; for example, an offset of 0 (zero) implies that text begins at 0. When offset is -1, the profil call is interpreted as a call to profile multiple discontiguous address ranges, such as those in an executable and its shared libraries. In this type of profil call, which has the format shown in the second synopsis above, the buffer_size parameter indicates the number of profil_args structures in the args array. Specifies the mapping factor between the program counter and short_buffer. When offset is -1, specifies an array of up to 64 struct profil_args structures, each describing a single address range in which profiling is to occur. Specifies flags that modify the behavior of a profil call that profiles multiple discontiguous address ranges. This argument is reserved for future use and should be 0. DESCRIPTION
The profil() function controls execution profiling. The short_buffer parameter points to an area of memory whose length (in bytes) is given by the buffer_size parameter. After this call, the process' program counter is examined at regular intervals (for example, at 1024 Hz). To determine the interval for your system, use the getsysinfo(2) system call with GSI_CLK_TCK as the operation parameter. The value of the offset parameter is subtracted from the program counter, and the result multiplied by the scale parameter. The corre- sponding location in the short_buffer parameter is incremented if the resulting number is less than the buffer_size parameter. The scale parameter is interpreted as an unsigned, fixed point fraction with 16 bits of mantissa: 0x10000 means that the address range has the same number of bytes as the short_buffer (that is, two bytes of instruction map into each short_buffer element); 0x8000 maps four bytes of instructions into each short_buffer element; and so on. The special scale factor of 2 maps all instructions onto the beginning of the short_buffer (producing a non-interrupting clock). Profiling is turned off by giving a scale parameter of either zero (0) or 1. Profiling is turned off when an execve() is executed. Pro- filing remains on in both the parent and child processes after a fork. Profiling is turned off if an update in the short_buffer parameter would cause a memory fault. If the process contains multiple threads, each will be independently sampled and the counts will reflect the sum of the samples for all of the threads. The second form of profil call allows you to profile multiple disjoint address ranges, such as an executable and its shared libraries. This form of profil call must specify an offset of -1. Its first argument, args, specifies an array of struct profil_args structures, each describing a single address range in which profiling is to occur. The buffer_size argument indicates the number of profil_args structures in the args array. The members of each profil_args structure in the array pointed to by args are similar to the arguments in the traditional profil call, except that the buffer field is an array of unsigned ints instead of an array of unsigned shorts, and the highpc and lowpc members specify both ends of the address range to be profiled. The scale is still the ratio of bytes in the address range to bytes in the buffer. The following are the contents of a profil_args struct: struct profil_args { unsigned int *buffer; void *highpc; void *lowpc void *offset; unsigned int scale; } All the address ranges specified in the array must be non-overlapping, and be ordered by decreasing lowpc value (that is, addresses ranges appear in the array in decreasing beginning address order). As with a traditional profil call, profiling is turned off (for a given address range) if an update in the buffer (specified by the struct profil_args for that address range) would cause a memory fault. You can stop profiling started by either type of profil call by issuing the following command: profil(0,0,0,0) Because a traditional profil call stops all profiling started with an extended call, and an extended profil call stops all profiling started with a traditional call, a thread never needs to record both kinds of profiling activity at the same time. That is, profiling a single address range with a buffer of short counters and profiling multiple address ranges in buffers with int counters are mutually exclusive in a given thread. Although a thread can be switched from one type of profiling to the other with any call to the other inter- face and different profiling mechanisms can operate on separate threads simultaneously, use of a single profiling interface is recommended in a single application. RELATED INFORMATION
Functions: exec(2), fork(2), getsysinfo(2), monitor(3) Commands: prof(1) delim off profil(2)
All times are GMT -4. The time now is 05:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy