Sponsored Content
Top Forums Shell Programming and Scripting Call function from Find command Post 302626629 by methyl on Thursday 19th of April 2012 01:19:05 PM
Old 04-19-2012
A function is a function within your current shell. We don't need to start another bash because we can just refer to the function like it is a command.
Guessing the $idir contains a valid comma-separated list of directories, we can rearrange the script to avoid using "for" when we have directory or file names.

This construct works for any number of files and for filenames containing space characters:

Code:
#Determine File Types.
fltyp()
{
	echo "$1"
}

#Find files and then send to fltyp function.
echo "${idir}" | tr ',' '\n' | while read directory
do
       find "${directory}" -type f -print | while read filename
       do
               # Call Function fltyp with the filename as a parameter
               fltyp "${filename}"
       done
done


Last edited by methyl; 04-19-2012 at 02:26 PM.. Reason: schoolboy error in input stream
This User Gave Thanks to methyl For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

function call

can I call a function in bash script just as in C++ while do function() done function() thanks, Steffen (3 Replies)
Discussion started by: forever_49ers
3 Replies

2. Programming

Help with a function call

Hi, Can anyone help me figure out the problem I'm having with a function call? I have a header file, which sets an enum: typedef enum {INFO, WARNING, FATAL} Levels; int log_event (Levels, char *fmt, ...); ..then the function is called this way: log_event(INFO, "Message text"); ... (6 Replies)
Discussion started by: Stevhp
6 Replies

3. Shell Programming and Scripting

call function

I have a function check_ok in my abc.sh. which return me 1 or 0 . I want to call this fuction through other shell script. this shell also send two parameter to calling function. Can you please tell me how. I am very new in unix. #!/bin/bash date_equal() { sqlplus -silent... (4 Replies)
Discussion started by: Jamil Qadir
4 Replies

4. Shell Programming and Scripting

help on function call

hello, when i call function inside awk traitement it doesn't work, i don't have error execution but i don't get result and if i call the function outside awk traitement it work well.. there's something special in awk call function?? here is the example : awk -F "," '{ {first=$1; sec=$2;... (3 Replies)
Discussion started by: kamel.seg
3 Replies

5. Shell Programming and Scripting

Function Call

How we can start a process if doesn't exists before? (1 Reply)
Discussion started by: Zaxon
1 Replies

6. Infrastructure Monitoring

diffrence between method call and function call in perl

Hello, I have a problem with package and name space. require "/Mehran/DSGateEngineLib/general.pl"; use strict; sub System_Status_Main_Service_Status_Intrusion_Prevention { my %idpstatus; my @result; &General_ReadHash("/var/dsg/idp/settings",\%idpstatus); #print... (4 Replies)
Discussion started by: Zaxon
4 Replies

7. Shell Programming and Scripting

Function call

Hi foiks i am unable to find what is wrong in my code mu functionality is to exit from shell when i give 99 but it is not calling function ext Could you please correct me. read option if ; then ext else echo "out" fi function ext { echo "tested 99 and exit... (12 Replies)
Discussion started by: kojo
12 Replies

8. Shell Programming and Scripting

use internal function with find command

Hi, I need to use a function in the find command to do some process on the file. I'm trying: funcname(){ ... } ... find ./ -name "*" -exec funcname {} \; But somehow this is not working. I don't want to have a separate script for whatever processing the function does. I want to have... (1 Reply)
Discussion started by: victorcheung
1 Replies

9. Shell Programming and Scripting

After exit from function it should not call other function

Below is my script that is function properly per my conditions but I am facing one problem here that is when one function fails then Iy should not check other functions but it calls the other function too So anyone can help me how could i achieve this? iNOUT i AM GIVING TO THE... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies

10. Shell Programming and Scripting

How to Call a Function

Hi I have created a function in a Shell Script test.sh function fnTest() { echo "My first Method } I have called this function in my test.sh cat abc.txt | grep "test" echo " test" fnTest But while running the shell script i got the following error: ... (2 Replies)
Discussion started by: nanthagopal
2 Replies
nidl(1ncs)																nidl(1ncs)

Name
       nidl - Network Interface Definition Language Compiler

Syntax
       nidl filename [options]

Description
       The compiler is for the Network Interface Definition Language (NIDL).

       The filename argument is the pathname of an interface definition file, written in the C syntax of NIDL.

       The compiler generates a header file, a client stub file, a server stub file, and a client switch file, all in C source code.  The compiler
       derives the names of these output files from filename by replacing the suffix (the rightmost period and	all  subsequent  characters)  with
       extensions for the client stub, server stub, and client switch.

Options
       -confirm 	   Display the options chosen but do not compile anything.  In displaying information about -idir, the compiler constructs
			   the list of all directories it would use to resolve relative pathnames of imported files, not just the ones	explicitly
			   supplied.  (If the list is empty, the compiler uses only the current directory.)  This option is useful for viewing the
			   `idir list' and for viewing the default values for other options.

       -cpp pathname	   Run the specified program instead of the default C preprocessor.  You can use the -confirm option to view  the  default
			   pathname.

       -def def1 [def2 ...]
			   Pass  the  specified  definitions  to  the  C  preprocessor.  A definition can take either of two forms: symbol or sym-
			   bol=value.

       -exts cstub-ext,sstub-ext,cswtch-ext
			   Set the extensions that the compiler uses to name the stub and switch files it generates.  The text strings	cstub-ext,
			   sstub-ext, and cswtch-ext must be separated by commas, with no spaces; they are used as extensions for the client stub,
			   the server stub, and the client switch, respectively.  You can use the -confirm option to view the defaults.

       -f77c		   Generate client switch code that is compatible with the ULTRIX compiler.  The NIDL compiler appends an  underscore  (_)
			   character to the name of each client switch routine, so that the routines can be called from FORTRAN programs generated
			   by the compiler.

       -f77s		   Generate server stub code that is compatible with the ULTRIX compiler.  The NIDL compiler  appends  an  underscore  (_)
			   character  to the name of each manager routine that the stub calls, so that the stub can call routines generated by the
			   compiler.

       -idir directory1 [directory2 ...]
			   Use the specified directories as paths from which to resolve relative pathnames of imported files.  The compiler gener-
			   ates  an  ordered  list  of these directories.  By default, it prepends to this list your current working directory and
			   appends the system directory.  You can suppress this default by supplying the -no_def_idir option.

       -m		   Support multiple versions and multiple managers within a single server.  This option allows a  server  to  export  more
			   than  one version of an interface (`multiple versions') and to implement an interface for more than one type (`multiple
			   managers').

			   The compiler appends the version number to the interface name when it generates identifiers	in  the  stub  and  header
			   files.  For example, the interface specifier for version 3 of the foobar interface would be foobar_v3$if_spec.

			   The server for an interface compiled with -m must use to register its managers.  The server supplies the name of a man-
			   ager EPV to the manager code defines this EPV.  If the server supports objects of several types, it must use to  regis-
			   ter	each  object.  These registrations enable the RPC runtime library at the server host to dispatch incoming requests
			   to the correct manager.

			   If you do not specify either -m or its counterpart, -s, the compiler assumes -s and issues a  warning.   However,  this
			   default may be removed or changed in future NIDL compilers.	Even if your server exports only one version of its inter-
			   face and contains only one manager, use the -m option, so that it will be easy for you to incorporate multiple versions
			   and multiple managers later.

       -no_cpp		   Do  not run the C preprocessor on the input file.  If you specify this option, the NIDL compiler does not interpret any
			   C preprocessor statements (such as statements) in the interface definition.

       -no_def_idir	   Do not prepend the current working directory or append the system directory to the list of directories constructed from
			   -idir  arguments.   If  you	specify -no_def_idir without -idir, the compiler resolves pathnames of imported files only
			   relative to the current working directory.

       -no_stubs	   Do not generate any stub or switch files.  The NIDL compiler generates only header files and insert files.

       -no_warn 	   Suppress warning messages.

       -out directory	   Place the generated files in directory.  The default is the current working directory.

       -s		   Allow a server to export only a single version of an interface and to implement an interface for only  a  single  type.
			   This  option  requests the behavior of NIDL compilers before Version 1.5, which added support for multiple versions and
			   multiple interfaces.  (See the -m option.)
			   The server for an interface compiled with -s must use to register its interfaces.
			   If you do not specify either -s or its counterpart, -m, the compiler assumes -s and issues a  warning.   However,  this
			   default may be removed or changed in future NIDL compilers.	Even if your server exports only one version of its inter-
			   face and contains only one manager, use the -m option, so that it will be easy for you to incorporate multiple versions
			   and multiple managers later.

       -space_opt	   Reduce the size of generated stub code, possibly at the expense of slower data marshalling.

       -version 	   Display the version number of the NIDL compiler but do not compile anything or generate any output files.

See Also
       uuid_gen(3ncs)
       DECrpc Programming Guide

																	nidl(1ncs)
All times are GMT -4. The time now is 02:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy