I did something like this to achieve this, you can refine this code further. Basic just here is if length of list is 1, then you need to check whether this has further some members or not.
To test this program it must create 2 integer lists - list1, list2 - and then read and process a series of list commands from a file named "data.txt". Each command and any associated values, list number, value appears on a separate line. All I can do is get it to input the integers and then... (3 Replies)
Hi All,
Need the help in getting the file list which are generated for the time period.
example if i want to get the list of file generated between 11 to 12 clock.
i used the find command search the files with -cmin flag with -60.
find /home/test/* -cmin -60 -type f -exec ls {} \;
... (2 Replies)
File_A contains Strings:
a
b
c
d
File_B contains Strings:
a
c
z
Need to have script written in either sh or ksh. Derive resultant files (File_New_A and File_New_B) from lists File_A and File_B where string elements in File_New_A and File_New_B are listed below.
Resultant... (7 Replies)
Hi everybody,
I'm trying to use a foreach command with two lists. The file.txt looks like this:
var1: 100 200 300
var2: 3 6 9
I'm trying to use a foreach command to associate the two variables together. My script looks like this:
#! /bin/tcsh
set a=(`cat file.txt | grep 'var1' | cut -d... (8 Replies)
Hi,
So I I received two lists for my merchandise and both are similar but differences do occur. I want to combine two lists that have similar names but I dont want the similar name to come up twice because I will end up purchasing two of those items. Heres an example below (file is massive). ... (1 Reply)
I expert,
I may cross post something similar but I dirtyed my quesion somehow to be clear in the thread
#cat file1
88dee gcc: Grok for callconvention-hard to enable hard float
a2ad2 eglibc: package mtrace separately
61487 python: bump PR of packages after update of distutils.bbclass... (1 Reply)
Hello everyone, I am new here forgive me if I omit something,
I have a problem which I can't seem to solve using TCL so I am posting it here.
Here it is :
I retrieve a UNKNOWN number of lists from an XML file. Let's skip the part where I retrieve these lists and say for example that you have... (4 Replies)
Hi togehter!
I would like to write an awk script which prints the first column divided by the sum of the second column:
So if this is my list
1 2
2 1
3 1
4 1
it should print a list like this:
1/5
2/5
3/5
4/5
My idea was to use END like this: (3 Replies)
Hey guys, so I wrote this simple script. The first time I typed it all out, I had the issue where whatever choice I entered, it would simply tell me it was a "bad selection" aka the else output.
I redid everything, and now no matter the choice, it does the backup option..
My brain hurts, and... (12 Replies)
Hello everybody.
My operating system is Fedora30, shell - bash
I faced combining lists. I will be glad for help regarding strings, arrays and so on.
The bottom line is as follows. It is necessary to combine each element from the first list with elements from the second.
if the second is longer... (4 Replies)
Discussion started by: nezabudka
4 Replies
LEARN ABOUT OPENSOLARIS
lindex
lindex(1T) Tcl Built-In Commands lindex(1T)__________________________________________________________________________________________________________________________________________________NAME
lindex - Retrieve an element from a list
SYNOPSIS
lindex list ?index...?
_________________________________________________________________DESCRIPTION
The lindex command accepts a parameter, list, which it treats as a Tcl list. It also accepts zero or more indices into the list. The |
indices may be presented either consecutively on the command line, or grouped in a Tcl list and presented as a single argument. |
If no indices are presented, the command takes the form: |
lindex list |
or |
lindex list {} |
In this case, the return value of lindex is simply the value of the list parameter. |
When presented with a single index, the lindex command treats list as a Tcl list and returns the index'th element from it (0 refers to the
first element of the list). In extracting the element, lindex observes the same rules concerning braces and quotes and backslashes as the
Tcl command interpreter; however, variable substitution and command substitution do not occur. If index is negative or greater than or
equal to the number of elements in value, then an empty string is returned. If index has the value end, it refers to the last element in
the list, and end-integer refers to the last element in the list minus the specified integer offset.
If additional index arguments are supplied, then each argument is used in turn to select an element from the previous indexing operation, |
allowing the script to select elements from sublists. The command, |
lindex $a 1 2 3 |
or |
lindex $a {1 2 3} |
is synonymous with |
lindex [lindex [lindex $a 1] 2] 3 |
EXAMPLES |
lindex {a b c} => a b c |
lindex {a b c} {} => a b c |
lindex {a b c} 0 => a |
lindex {a b c} 2 => c |
lindex {a b c} end => c |
lindex {a b c} end-1 => b |
lindex {{a b c} {d e f} {g h i}} 2 1 => h |
lindex {{a b c} {d e f} {g h i}} {2 1} => h |
lindex {{{a b} {c d}} {{e f} {g h}}} 1 1 0 => g |
lindex {{{a b} {c d}} {{e f} {g h}}} {1 1 0} => g |
SEE ALSO list(1T), lappend(1T), linsert(1T), llength(1T), lsearch(1T), lset(1T), lsort(1T), lrange(1T), lreplace(1T) |
KEYWORDS
element, index, list
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+--------------------+-----------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+--------------------+-----------------+
|Availability | SUNWTcl |
+--------------------+-----------------+
|Interface Stability | Uncommitted |
+--------------------+-----------------+
NOTES
Source for Tcl is available on http://opensolaris.org.
Tcl 8.4 lindex(1T)