Sponsored Content
Top Forums Shell Programming and Scripting How to pass and read an array in ksh shell script function.? Post 303039894 by apmcd47 on Thursday 17th of October 2019 06:19:38 AM
Old 10-17-2019
Would name referencing be useful? This is Corona688's solution using namerefs:
Code:
#!/bin/ksh

set -A filelist val1 val2 val3
set -A otherlist q1 q2 q3

verifyfiles() {
   nameref Flist=$1
   nameref Qlist=$2
   echo "flist[0]=${Flist[0]}"
   echo "qlist[0]=${Qlist[0]}"
}

verifyfiles filelist otherlist

As you are passing by reference you can actually change the contents of the original array, which is probably a bad thing.

Andrew
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to pass arguments to a function in a shell script?

Hi, I have two shell variables $t1 and $t2 which I need to pass to a function in a shell script. The function will do some computation with those two variables and echo the resultant. But I do not know how to pass teh arguments. The function written is f1() {...... ........ } What should... (3 Replies)
Discussion started by: preetikate
3 Replies

2. Shell Programming and Scripting

How to read values that are passed to the shell function in ksh.

In ksh shell, There is a function f1. function f1 { How to read here?? .... .... } I am passing values to fuunction f1 as f1 "A" "B" Please tell me how to read the passed values in function f1. Advance Thanks & Regards Prashant (2 Replies)
Discussion started by: prashant43
2 Replies

3. Shell Programming and Scripting

How to pass an array from SHELL to C function

Hi, I have an output generated from a shell script like; 0x41,0xF2,0x59,0xDD,0x86,0xD3,0xEF,0x61,0xF2 How can I pass this value to the C function, as below; int main(int argc, char *argv) { unsigned char hellopdu={above value}; } Regards Elthox (1 Reply)
Discussion started by: elthox
1 Replies

4. Programming

How to pass C array as input to Shell script

Hi, In the below C code , i want to pass the array to a unix shel script. my script should called as ex myscript 1,2,3 #include <stdio.h> int main() { int a={1,2,3}; } Thanks, Arun (1 Reply)
Discussion started by: arunkumar_mca
1 Replies

5. Shell Programming and Scripting

What is the maximum number of parameter we can pass to a shell script function?

what is the maximum number of parameter we can pass to a shell script function (8 Replies)
Discussion started by: alokjyotibal
8 Replies

6. Shell Programming and Scripting

How to pass parameter to User defined function in shell script?

Hello, Can anyone guide me tin passing parameters into user defined function of shell script (KSH). Here is my code, InsertRecord() { DB_TBL=$(sqlplus $USERID/$PASSWORD@$DATABASE << EOF set head off set feed off set serveroutput on INSERT INTO TBL1 ( OLD_VAL, NEW_VAL, ... (7 Replies)
Discussion started by: Poonamol
7 Replies

7. Shell Programming and Scripting

How to pass an array to a function in shell script.?

hi, I have a array say SAP_ARRAY="s1.txt" SAP_ARRAY="s2.txt" how can i pass this full array to a function. here is the sample code i am using.. CHECK_NO_FILES() { FARRAY=$1 echo "FARRAY = $FARRAY" echo "FARRAY = $FARRAY" ............... (5 Replies)
Discussion started by: Little
5 Replies

8. Shell Programming and Scripting

Pass array to a function and display the array

Hi All I have multiple arrays like below. set -A val1 1 2 4 5 set -A val2 a b c d . . . Now i would like to pass the individual arrays one by one to a function and display/ do some action. Note : I am using ksh Can you please advise any solution... Thanks in advance. (7 Replies)
Discussion started by: Girish19
7 Replies

9. Shell Programming and Scripting

Pass C shell array to another C shell script(csh) and shell(sh)

Dear Friends, Please help me on this my script name is send.csh In this i have written the statement like this set args = ( city state country price ) I want to pass this array to another c shell called receiver.csh. and i want to use it in this c shell or how to pass to... (2 Replies)
Discussion started by: SA_Palani
2 Replies

10. Shell Programming and Scripting

Shell script to pass the config file lines as variable on the respective called function on a script

I want to make a config file which contain all the paths. i want to read the config file line by line and pass as an argument on my below function. Replace all the path with reading config path line by line and pass in respective functions. how can i achieve that? Kindly guide. ... (6 Replies)
Discussion started by: sadique.manzar
6 Replies
FLIST(1)                                                             [nmh-1.5]                                                            FLIST(1)

NAME
flist, flists - list the number of messages in given sequence(s) SYNOPSIS
flist [+folder1 [+folder2 ...]] [-sequence name1 [-sequence name2 ...]] [-all | -noall] [-showzero | -noshowzero] [-recurse | -norecurse] [-fast | -nofast] [-alpha | -noalpha] [-version] [-help] flists is equivalent to flist -all DESCRIPTION
Flist is used to search a list of folders and display the number of messages in these folders that are in a given sequence or set of sequences (for example the "unseen" sequence). This is especially useful if you use some mechanism such as slocal or procmail (typically in conjunction with rcvstore) to pre-sort your mail into different folders before you view it. By default, the command flist will search the current folder for the given sequence or sequences (usually "unseen"). If (possibly multi- ple) folders are specified on the command line with +folder, then all these folders are searched for the given sequence(s). Flist will display for each folder searched, the number of messages in each of the specified sequences, and the total number of messages. The option -sequence is used to specify the name of a sequence in which to search for. This option may be used multiple times to specify multiple sequences. If this is not given, then the default is to search for all the sequences specified by the "Unseen-Sequence" profile component. For more details about sequences, read the mh-sequence(5) man page. Typically, flist will produce a line for each sequence, for every folder that is searched, even those which do not contain any messages in the given sequence. Specifying -noshowzero will cause flist to print only those folder/sequence combinations such the folder has a non- zero number of messages in the given specified sequence. If -recurse is given, then for each folder that is search, flist will also recursively descend into those folders to search subfolders for the given sequence. If -fast is given, only the names of the folders searched will be displayed, and flist will suppress all other output. If this option is used in conjunction with -noshowzero, then flist will only print the names of those folders searched that contain messages in in at least one of the specified sequences. Multiple Folders If the option -all is given (and no folders are specified with +folder), then flist will search all the folders in the top level of the users nmh directory. These folders are all preceded by the read-only folders, which occur as "atr-cur-" entries in the user's nmh context. An example of the output of flist -all is: /work/Mail has 5 in sequence unseen (private); out of 46 inbox+ has 10 in sequence unseen ; out of 153 junklist has 0 in sequence unseen ; out of 63 postmaster has 1 in sequence unseen ; out of 3 The "+" after inbox indicates that it is the current folder. The "private" flag indicates that the given sequence for that folder is private. See the mh-sequence(5) man page for details about private sequences. If the option -all and +folder are both specified, then flist will search this folder, and all its first level subfolders for the given sequence. You may specify multiple folders in this way. If flist is invoked by a name ending with "s" (e.g. flists), then the switch -all is assumed by default. The sorting order for the listing is alphabetical (with -alpha), or in a priority order defined by the "Flist-Order" profile entry (with -noalpha). Each item in the "Flist-Order" is a folder name or a folder name pattern that uses * to match zero or more characters. Longer matching patterns have precedence over shorter matching patterns. For example: Flist-Order: personal petproject mh* * admin *junk This order puts a few interesting folders first, such as those with mail addressed to you personally, those about a pet project, and those about mh-related things. It places uninteresting folders at the end, and it puts everything else in the middle in alphabetical order. FILES
$HOME/.mh_profile The user profile PROFILE COMPONENTS
Path: To determine the user's nmh directory mh-sequences: File that contains public sequences Unseen-Sequence: The name of the unseen message sequence Flist-Order: To sort folders by priority SEE ALSO
folder(1), rcvstore(1), slocal(1), mh-sequence(5) DEFAULTS
`-sequence' defaults to Unseen-Sequence profile entry `-showzero' `-noall' `-norecurse' `-noalpha' `-nofast' CONTEXT
If +folder is given, it will become the current folder. If multiple folders are given, the last one specified will become the current folder. MH.6.8 11 June 2012 FLIST(1)
All times are GMT -4. The time now is 05:20 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy