Visit Our UNIX and Linux User Community

Full Discussion: Array Element
Top Forums UNIX for Advanced & Expert Users Array Element Post 302927833 by sea on Friday 5th of December 2014 09:41:39 PM
Old 12-05-2014
You could also use a conf file for all those entries....
Even if it looks as simple as this:

While just reading from such a file is very easy using IFS="=" and a while read, any kind of 'dynamic' reading of a certain variable might become more complex.

There is the option to save each entry into a single file.

I just had help to avoid shell injection with my scripts regarding conf file modification Reading and Writing a conf file - Suggestions and improvements?.

Their function:
# List all variables (NOT values!)
tui-conf-get -l "FILE"

# Get value
tui-conf-get "FILE" "VAR"

# Set value
tui-conf-set "FILE" "VAR" "VAL"

Maybe they could be of help?
Test Your Knowledge in Computers #82
Difficulty: Easy
DOS was based on Unix.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

accessing my first element of array

Hello everyonel, I have an array set like so num=4 read name arr=name I go through while loop to assign different values to different array element from 1 to 4. when I try to access the FIRST element of the array I get the last one first. Like if I say ${arr} it will show the last element... (4 Replies)
Discussion started by: afadaghi
4 Replies

2. 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

3. Shell Programming and Scripting

Shift array element

I want to delete and 0th element of array in shell scrpit and also shift all others to one level up. (2 Replies)
Discussion started by: darshakraut
2 Replies

4. Shell Programming and Scripting

HELP unsetting array element in loop

I have a loop and I need to be able to unset the array element that I am currently accessing in it. I was thinking of making a counter that increments with the loop and doing unset $dirs but if I do that I am not sure if the other members of the array would get shifted down in index (meaning that... (2 Replies)
Discussion started by: msf5042
2 Replies

5. Shell Programming and Scripting

remove an element from array

I need to remove an element from the below array variable TABLENAME. #!/bin/ksh set -A TABLENAME "mirf roxar keke mirs" echo "the array is ${TABLENAME}" If i need to remove say keke and have the final TABLENAME as below, how this could be achieved. Pls throw some light. echo "Modified... (3 Replies)
Discussion started by: michaelrozar17
3 Replies

6. 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

7. Shell Programming and Scripting

previous element in the array perl

Hi, How to get previous/next element in the array perl Example @queue = (1, 2 ,3 , 4); I want to get value of 1 and 2, or, 2 and 3, or 3 and 4...etc and compare to value which one is greater to do that I need to get previous and next element of array ? (1 Reply)
Discussion started by: guidely
1 Replies

8. Emergency UNIX and Linux Support

Assigning zero to element of ksh array.

set -A matched #find referenced files. for i in ${file_names_html} do counter_j=0 for j in ${file_names_minus_index} do match=`cat $i | grep... (1 Reply)
Discussion started by: robin_simple
1 Replies

9. Programming

How to delete a duplicate element from below array.

Hello forum , Please solve the below queery. A sorted array which has repated elements. A = {1,2,3,3,4,5,5,5,6,9,9} i want to delete the duplicate elements and to genrate a new array. i need the array sholud be like this A = {1,2,3,4,5,6,9}. Please write the piece of code... (4 Replies)
Discussion started by: workforsiva
4 Replies

10. Shell Programming and Scripting

Multiplying array element

I am trying to take all the elements of an array and multiply them by 2, and then copy them to a new array. Here is what I have i=0 for true in DMGLIST do let DMGSIZES2="${DMGSIZES}"*2 let i++ done unset i echo ${DMGSIZES2} It does the calculation correctly for the first element,... (7 Replies)
Discussion started by: nextyoyoma
7 Replies
SVN::Hooks::UpdateConfFile(3pm) 			User Contributed Perl Documentation			   SVN::Hooks::UpdateConfFile(3pm)

SVN::Hooks::UpdateConfFile - Maintain the repository configuration versioned. VERSION
version 1.19 SYNOPSIS
This SVN::Hooks plugin allows you to maintain the repository configuration files under version control. The repository configuration is usually kept in the directory "conf" under the directory where the repository was created. In a brand new repository you see there the files "authz", "passwd", and "svnserve.conf". It's too bad that these important files are usually kept out of any version control system. This plugin tries to solve this problem allowing you to keep these files versioned under the same repository where they are used. It's active in the "pre-commit" and the "post-commit" hooks. It's configured by the following directive. UPDATE_CONF_FILE(FROM, TO, @ARGS) This directive tells that after a successful commit the file FROM, kept under version control, must be copied to TO. FROM can be a string or a qr/Regexp/ specifying the file path relative to the repository's root (e.g. "trunk/src/version.c" or "qr:^conf/(w+).conf$:"). TO is a path relative to the "/repo/conf" directory in the server. It can be an explicit file name or a directory, in which case the basename of FROM is used as the name of the destination file. If FROM is a qr/Regexp/, TO is evaluated as a string in order to allow for the interpolation of capture buffers from the regular expression. This is useful to map the copy operation to a diferent directory structure. For example, this configuration "qr:^conf/(w+).conf$: => '$1.conf'" updates any .conf file in the repository conf directory. The optional @ARGS must be a sequence of pairs like these: validator => ARRAY or CODE A validator is a function or a command (specified by an array of strings that will be passed to the shell) that will check the contents of FROM in the pre-commit hook to see if it's valid. If there is no validator, the contents are considered valid. The function receives three arguments: A string with the contents of FROM A string with the relative path to FROM in the repository An SVN::Look object representing the commit transaction The command is called with three arguments: The path to a temporary copy of FROM The relative path to FROM in the repository The path to the root of the repository in the server generator => ARRAY or CODE A generator is a function or a command (specified by an array of strings that will be passed to the shell) that will transform the contents of FROM in the post-commit hook before copying it to TO. If there is no generator, the contents are copied as is. The function receives the same three arguments as the validator's function above. The command is called with the same three arguments as the validator's command above. actuator => ARRAY or CODE An actuator is a function or a command (specified by an array of strings that will be passed to the shell) that will be invoked after a successful commit of FROM in the post-commit hook. The function receives the same three arguments as the validator's function above. The command is called with the same three arguments as the validator's command above. rotate => NUMBER By default, after each successful commit the TO file is overwriten by the new contents of FROM. With this option, the last NUMBER versions of TO are kept on disk with numeric suffixes ranging from .0 to ".NUMBER-1". This can be useful, for instance, in case you manage to commit a wrong authz file that denies any subsequent commit. UPDATE_CONF_FILE( 'conf/authz' => 'authz', validator => ['/usr/local/bin/svnauthcheck'], generator => ['/usr/local/bin/authz-expand-includes'], actuator => ['/usr/local/bin/notify-auth-change'], rotate => 2, ); UPDATE_CONF_FILE( 'conf/svn-hooks.conf' => 'svn-hooks.conf', validator => [qw(/usr/bin/perl -c)], actuator => sub { my ($contents, $file) = @_; die "Can't use Gustavo here." if $contents =~ /gustavo/; }, rotate => 2, ); UPDATE_CONF_FILE( qr:/file( +)$:' => 'subdir/$1/file', rotate => 2, ); AUTHOR
Gustavo L. de M. Chaves <> COPYRIGHT AND LICENSE
This software is copyright (c) 2012 by CPqD. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. perl v5.14.2 2012-06-24 SVN::Hooks::UpdateConfFile(3pm)

Featured Tech Videos

All times are GMT -4. The time now is 05:01 AM.
Unix & Linux Forums Content Copyright 1993-2021. All Rights Reserved.
Privacy Policy