Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

lappend(ntcl) [osx man page]

lappend(n)						       Tcl Built-In Commands							lappend(n)


lappend - Append list elements onto a variable SYNOPSIS
lappend varName ?value value value ...? _________________________________________________________________ DESCRIPTION
This command treats the variable given by varName as a list and appends each of the value arguments to that list as a separate element, with spaces between elements. If varName does not exist, it is created as a list with elements given by the value arguments. Lappend is similar to append except that the values are appended as list elements rather than raw text. This command provides a relatively efficient way to build up large lists. For example, "lappend a $b" is much more efficient than "set a [concat $a [list $b]]" when $a is long. EXAMPLE
Using lappend to build up a list of numbers. % set var 1 1 % lappend var 2 1 2 % lappend var 3 4 5 1 2 3 4 5 SEE ALSO
list(n), lindex(n), linsert(n), llength(n), lset(n), lsort(n), lrange(n) KEYWORDS
append, element, list, variable Tcl lappend(n)

Check Out this Related Man Page

lrange(n)						       Tcl Built-In Commands							 lrange(n)


lrange - Return one or more adjacent elements from a list SYNOPSIS
lrange list first last _________________________________________________________________ DESCRIPTION
List must be a valid Tcl list. This command will return a new list consisting of elements first through last, inclusive. The index values | first and last are interpreted the same as index values for the command string index, supporting simple index arithmetic and indices rela- | tive to the end of the list. If first is less than zero, it is treated as if it were zero. If last is greater than or equal to the number of elements in the list, then it is treated as if it were end. If first is greater than last then an empty string is returned. Note: "lrange list first first" does not always produce the same result as "lindex list first" (although it often does for simple fields that are not enclosed in braces); it does, however, produce exactly the same results as "list [lindex list first]" EXAMPLES
Selecting the first two elements: % lrange {a b c d e} 0 1 a b Selecting the last three elements: % lrange {a b c d e} end-2 end c d e Selecting everything except the first and last element: % lrange {a b c d e} 1 end-1 b c d Selecting a single element with lrange is not the same as doing so with lindex: % set var {some {elements to} select} some {elements to} select % lindex $var 1 elements to % lrange $var 1 1 {elements to} SEE ALSO
list(n), lappend(n), lindex(n), linsert(n), llength(n), lsearch(n), lset(n), lreplace(n), lsort(n), string(n) | KEYWORDS
element, list, range, sublist Tcl 7.4 lrange(n)
Man Page

11 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Forking with Tclsh vs Wish

Hello, I am new to this site, so sorry ahead of time if this is not the right place for this question.......anywhooooo I am having troubles with forking new processes in wish. Take the following code example: **************************** package require Tclx puts "TCL VER: " proc... (3 Replies)
Discussion started by: pghamami
3 Replies

2. Shell Programming and Scripting

tcl problem

I'm trying to write a script that will do the following: Open a text file for reading/writing. Read each line. When I find a specfic value in a line, append something to the end of that line. I loop through and read all the lines in myfile.txt looking for dev123_data_log and find a... (5 Replies)
Discussion started by: progkcp
5 Replies

3. Shell Programming and Scripting

Concatenate some of the rows...

i have a file as below and i need to load it into oracle. The problem is, some of the rows are in 2 lines. 123456_PosWlist ----- ----- IN 0/0 123456_PosWListRpt ----- ----- IN 0/0 123456_PosWListCSV ----- -----... (7 Replies)
Discussion started by: Amit.Sagpariya
7 Replies

4. Shell Programming and Scripting

expect script hangs while waiting for the flag...

I am writing a script to check whether the root password is set to a special string on some solaris servers. Normally, the manually ssh login session is as below: $ ssh root@host1 Password: Last login: Wed Sep 16 13:53:28 2009 from Sun Microsystems Inc. SunOS 5.10 ... (4 Replies)
Discussion started by: sleepy_11
4 Replies

5. Shell Programming and Scripting

Problem with Cron job

Hi , I have a TCL script which i am supposed to run as a cron job.. The script works fine from command line , but when run as a cron job , its unable to find a package,, my crontab is as follows. --------------------------- #!/usr/bin/ksh * * * * * PATH=/cm8/auto/Automation/Library/TclLib ... (7 Replies)
Discussion started by: Sudharshana
7 Replies

6. Shell Programming and Scripting

expect problem

hi all, guys i have a problem in this code... any help ? #!/usr/bin/expect if { $argc != 3 } { puts "Usage:" puts "$argv0 username oldpwd newpwd" exit } #set machine set username set oldpwd set newpwd set completed_list " " (2 Replies)
Discussion started by: b1sh0p
2 Replies

7. Shell Programming and Scripting

Getting error while sending mail via smtp

Hi All, I used before a simple routine code in tcl to send mail. package require smtp package require mime package require Tcl proc send_simple_message {recipient email_server subject body} { set token mime::setheader $token Subject $subject smtp::sendmessage $token \ ... (0 Replies)
Discussion started by: zivsegal
0 Replies

8. UNIX for Advanced & Expert Users

Array Operations in tcl

I would like to create an array using tcl script which takes in name, id, and marks of many people in 3 subjects. I would like calculate the total marks of each person and rank them according to their marks. Taking name as my key for access i want to do sort and rank the person based on highest... (3 Replies)
Discussion started by: Carlton
3 Replies

9. Programming

Tcl script

Dear Users I'm struck by while the following tcl script. foreach l { set w($l) {} set fsum 0 foreach ftemp $f($l) { set fsum lappend w($l) $fsum } } It shows me error as "missing operand at _@_ in expression "0.10308400000000001 + _@_* 0.4 * 1" ... (0 Replies)
Discussion started by: bala06
0 Replies

10. Shell Programming and Scripting

How to get user to choose files to be copied to FTP server?

Hey all. I'm writing a script to automatically login to a router, change directories to where crashfiles are located, then listing all files in that directory. This is where I'm at so far and wish to have some user interaction to choose the files. What I am trying to do is list the files and get... (1 Reply)
Discussion started by: Gouda
1 Replies

11. Shell Programming and Scripting

Need to call tcl function from other file !!

Hi, Can a function written in tcl in some other file be called in unix scripts ? Like this ? This is my code now--- #!/bin/bash tclsh snmpv2-conf-sam.tcl $SERVER $NODESYSIP $SPASSWD but i need this in a different way like , without having a .tcl file i want the... (2 Replies)
Discussion started by: giri_luck
2 Replies