Sponsored Content
Top Forums Shell Programming and Scripting Adding an element to a bash array with a variable Post 302937960 by Don Cragun on Wednesday 11th of March 2015 02:32:50 AM
Old 03-11-2015
It also seems that a simple string, rather than an array, might be a simpler approach here. When you get to the point that you want to invoke a command, I would assume that you would want -L 22 -s 0 -r -O -A i -N 100 -n to be eleven separate arguments to that command; not a single argument.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Adding array element in KSH

All, I would like to add the first 10 elements of an array. Here is how I am doing it now (only included first few add ops): #!/usr/bin/ksh ###Grab the array values out of a file### TOTAL=`awk '/time/' /tmp/file.out | awk '{print $4}'` set -A times $TOTAL SUM=$((${times} + times... (3 Replies)
Discussion started by: Shoeless_Mike
3 Replies

2. Shell Programming and Scripting

saving awk value in a bash array variable

hi all i am trying to save an awk value into an array in bash: total=`awk '{sum+=$3} END {print sum}' "$count".txt"` ((count++)) the above statement is in a while loop.. $count is to keep track of file numbers (1.txt,2.txt,3.txt,etc.) i get the following error: ./lines1:... (1 Reply)
Discussion started by: npatwardhan
1 Replies

3. Windows & DOS: Issues & Discussions

Array element & string variable

Hello, I am trying to assign $string = $a; #a= 10100 print " $string"; # showing 10100 I am using this $string as $result = index($string, $char, $offset); As above, is not capturing binary nos. in following format; $string = '10100'; so index is not working. kindly suggest. (5 Replies)
Discussion started by: shristi
5 Replies

4. Shell Programming and Scripting

How to assign an array element to a variable

Hi every one.. I'm new to shell scripting... I would like to assign a single array element to a variable... Is it possible to do it.... Could any body help me.... (3 Replies)
Discussion started by: kaushik_87
3 Replies

5. Shell Programming and Scripting

Creating bash array name from variable

Hi gurus, I need to create arrays from variables, via a loop. The issue I have is with the array name creation. How do I use a variable to define an array? I want to do something like declare -a $H where $H is my loop variable. I then need to add items to each array I've created,... (3 Replies)
Discussion started by: melias
3 Replies

6. Shell Programming and Scripting

Adding Content to Variable (bash)

is this possible? its kind of like incrementing the value of a number in a variable. but in this case, instead of the value of the variable being a number, it's just contents/strings/characters/alpha-numeric etc. NOT a number. For instance: VAR=Tommy for all in $(blah blah) do ... (2 Replies)
Discussion started by: SkySmart
2 Replies

7. Shell Programming and Scripting

Bash question: working with an array of previously set variable strings

while i've used arrays to work with variables, i've never used them to loop through a set of strings and wanted to ask the community for some feedback or assistance. let me be specific. here's my code: # URL port Variables port2195=`nc -z $url2195 2195` port2196=`nc -z $url2196 2196`... (5 Replies)
Discussion started by: hungryd
5 Replies

8. UNIX for Advanced & Expert Users

Array Element

This question is for someone that's more familiar with Array Element. I need to know if the maximum array element that can be assigned is 1024 and if its so, Is there a workaround solution when the counter exceeded 1024? param_array="$param_nam" counter=$counter+1 #to avoid space... (3 Replies)
Discussion started by: cumeh1624
3 Replies

9. UNIX for Beginners Questions & Answers

Unset array element and save to file in Bash

#!/bin/bash X=(2H 4S 10D QC JD 9H 8S) How do I unset the 10D from this array and save it to a file? Please use CODE tags as required by forum rules! (5 Replies)
Discussion started by: cogiz
5 Replies

10. UNIX for Beginners Questions & Answers

Adding to an array in an external file, and adding elements to it.

I have an array in an external file, "array.txt", which contains: char *testarray={"Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"};I want to be able to add an element to this array, and have that element display, whenever I call it, without having to recompile... (29 Replies)
Discussion started by: ignatius
29 Replies
getsubopt(3)						     Library Functions Manual						      getsubopt(3)

NAME
getsubopt - Parses suboption arguments from a command line LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <stdlib.h> int getsubopt( char **optionp, char *tokens[], char **valuep); STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: getsubopt(): XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies the address of a pointer to the option string. Specifies an array of possible suboption tokens. Specifies the address of a value string pointer. DESCRIPTION
The getsubopt() function parses suboption arguments in a flag argument that was initially parsed by the getopt() function. These suboption arguments must be separated by commas and may consist of either a single token, or a token-value pair separated by an equal sign. Because commas delimit suboption arguments in the option string, commas are not allowed to be part of the suboption arguments or the value of a suboption argument. Similarly, because the equal sign separates a token from its value, a token must not contain an equal sign. The following command line for the mount command gives an example of this syntax: mount -o ro,nosuid,rsize=8192 paradox:/u2 /u2 In this example, the suboption consists of three arguments: ro and nosuid (tokens), and rsize=8192 (a token-value pair). When a suboption argument is found in the *optionp string that matches a string in the token array, the index of the matching string in the array is returned. If no match is found, then a -1 is returned. After each match, the *optionp string is updated to point past the matched suboption argument to the next suboption argument in the list. If the suboption argument matched is the last in the string, *optionp is set to the null pointer. If the suboption argument matched is a token-value pair, then *valuep is set to point to the value. If there is no value, then *valuep is to the null pointer. The token array is a list of pointers to strings. The end of the array is signified by a NULL pointer. RETURN VALUES
Upon successful completion, the getsubopt() function returns the index of the token or suboption argument that matches the suboption argu- ment in the input string. Otherwise, if no match is found, it returns a value of -1. ERRORS
No errors are defined for this routine. RELATED INFORMATION
Functions: getopt(3) Standards: standards(5) delim off getsubopt(3)
All times are GMT -4. The time now is 02:41 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy