Sponsored Content
Full Discussion: array to choices .. lost
Top Forums Shell Programming and Scripting array to choices .. lost Post 302381866 by zaxxon on Monday 21st of December 2009 07:45:43 AM
Old 12-21-2009
Maybe this script is an option for you; I did not alter your script just wrote it new:
Code:
#!/bin/bash

ARR=( `ls -1 file*` )
Z=1

for ELE in ${ARR[*]}; do
        printf "%-5d%-50s\n" $Z $ELE
        Z=$(($Z+1))
done

echo "--------------------------------"
read INPUT

I=$(($INPUT-1))
echo "You pressed [${INPUT}] for file [${ARR[${I}]}]"

exit 0

Output:
Code:
$> ll file*
-rw-r--r-- 1 root root 0 2009-12-21 13:23 file1
-rw-r--r-- 1 root root 0 2009-12-21 13:23 file2
-rw-r--r-- 1 root root 0 2009-12-21 13:23 file3
$> ./mach.ksh
1    file1
2    file2
3    file3
--------------------------------
2
You pressed [2] for file [file2]

If there could be a situation where there is no file, there will be an error so you might want to check additionally for files to fill your array 1st.

Last edited by zaxxon; 12-21-2009 at 09:31 AM.. Reason: Added info; shortened it and defined array directly
 

4 More Discussions You Might Find Interesting

1. Filesystems, Disks and Memory

Lost Data Lost Admin

First time so excuse my ignorance please. I may not be accurately describing the issue. I have inherited a small lab mostly SUN V120s. We lost power and are trying to recover. Nope no backups... The primary issue I have is 1 box is an Oracle Server. It has 2 36Gb harddrives. I am able to... (3 Replies)
Discussion started by: murphsr
3 Replies

2. Shell Programming and Scripting

Generating a list of choices in a menu

Hello all, I have the below script and I'm a little stuck on the best way to continue. Essentially I'm creating a text file (systems.txt) with a list of servers in it by hostname. Then I would like to echo a menu with each hostname and a number to use to pick it from the list. It's somehow... (7 Replies)
Discussion started by: sysera
7 Replies

3. Shell Programming and Scripting

Attempting to pass my array as a nested parameter to loop. A little lost.

I want to pass this array as a parameter. IFS=$'\n' fortune_lines=($(fortune | fold -w 30 )) Inside of this line screen -p 0 -S ${SCREEN_SESSION} -X stuff "`printf "say ${fortune_lines}\r"`" And I am lost at this point. I am thinking something like this? Then make it loop.. ... (7 Replies)
Discussion started by: briandanielz
7 Replies

4. Solaris

Lost out-of-band communication with 2540 Array

Hello Dears, My server hots cannot contacted my array disk 2540 by using out-of-band Ethernet Cable. The Controller Ethernet port is off , I replace the ethernet cable but not OK I reboot the server and the Array disk 2540 but Not OK. Please somebody know how to solve this issue? ... (1 Reply)
Discussion started by: ghislino
1 Replies
DEBCONF-GETTEXTIZE(1)						    po-debconf						     DEBCONF-GETTEXTIZE(1)

NAME
       debconf-gettextize - extract translations of debconf templates into PO files

SYNOPSIS
       debconf-gettextize [-v] [-h] [--podir=DIR] [--choices] [--merge] master [master ...]

DESCRIPTION
       The /var/lib/dpkg/info/*.templates files read by debconf contain English text and translations in the same file.  But in source packages,
       translations are managed in separate files to help translators.	In the initial implementation, a master templates file contained only
       English text, and templates.xx files contained both original and translated strings for the language xx.  The debconf-mergetemplate program
       was merging master and translated templates files.

       The new implementation with "po-debconf" is based on "gettext".	Maintainers mark translatable fields by prepending them with an
       underscore, English strings are automatically extracted into a POT file, translators work on normal PO files, and po2debconf generates a
       merged templates file with the same structure.

       The debconf-gettextize program was initially designed to help migrating to the new implementation.

       o It reads a list of master files and their associated translations, and generates po/*.po files for each language containing translated
	 strings.

       o Each input file receives an ".old" suffix, and a new master file overwrites the old one; it is identical to the previous master file
	 except that an underscore is prepended to translatable fields.  Developers can then choose which fields translators have to work on and
	 which ones are skipped because their values are not locale-dependent.

       o A po/POTFILES.in file is also created, it contains the list of templates files debconf-updatepo has to process.

       Typically the debconf-gettextize program must be run only once when transforming from the first implementation to the "po-debconf" format,
       but it can also be used afterwards to transform a "_Choices" field into "__Choices" (or vice-versa) without losing translations, when using
       the "--merge" flag (alongside with "--choices" or not).	The desired template containing the "_Choices" or "__Choices" fields to modify has
       to be copied into a temporary template file, which is passed to debconf-gettextize as an argument.  Then the following steps are performed:

       1. po2debconf is run on this template file to generate a translated templates file.

       2. This translated templates file is processed as described above and PO files are generated.

       3. Newly created PO files are merged with existing ones.

       When PO files are merged, "_Choices" fields have to be replaced by "__Choices" (or vice-versa) in the original templates file before
       running debconf-updatepo, otherwise new translations will be fuzzy.

OPTIONS
       -h, --help
	   Display a usage summary for the program and exit.

       -v, --verbose
	   Process in verbose mode.

       --podir=DIR
	   Set directory for PO files.	Default is to search for PO files in the po subdirectory below the location of the first master file.

       --choices
	   By default, debconf-gettextize replaces "Choices" fields by "_Choices".  With this flag, "__Choices" fields are written instead.

       --merge
	   When this flag is set, the strings are merged with existing PO files.  The templates files and po/POTFILES.in are not modified.

CAVEATS
       The "Default" field is special when template type is "Select" or "Multiselect", because a value has to be chosen amongst the English list
       of choices, even for localized values.  Normally this field must not be changed, but in rare circumstances localized values are meaningful
       (e.g. to choose the default language of an application).  In order to let translators know that this localized "Default" field is special,
       you must by convention call it "_DefaultChoice" instead of "_Default".

SEE ALSO
       debconf-updatepo(1), po2debconf(1), debconf-devel(7), po-debconf(7).

AUTHORS
	 Denis Barbier <barbier@linuxfr.org>
	 Martin Quinson <martin.quinson@ens-lyon.fr>

								    2016-10-01						     DEBCONF-GETTEXTIZE(1)
All times are GMT -4. The time now is 01:23 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy