I haven't tested this in Sun/Solaris box but I think you have to call the second function at last to execute it. So following you could try and let us know how it goes then. NOTE: I have tested above in BASH and worked fine for me.
I am sorry but it is still not clear what you want to do, if you want to create some functions and call them according to number then you could useswitch case. Now coming to your requirement in case you wanted to print lines from 6th to 9th then you should mention sed outside of the Input_file as follows.
I have removed | shin command sed -n 6,9p Input_file as you wanted to simply print lines. As I have mentioned before in case you wanted to execute some commands which you are printing from sed and wanted to execute you could use | sh then.
Now in case you wanted to use sed within your script itself then you could do following with the use of EOF.
If above both solutions are not matching your requirement, request you to be more precise in your requirement and provide us all the inputs from your side, I hope this helps.
Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
When I run :
(assuming that the numbers in your script are not there in real life) I get:
So these are the four lines of your code that get piped into a new Bourne shell (sh), which is like a new script and in that script firstfunc() is not defined.
--
Also note:
In your second example you are not using: #!/usr/xpg4/bin/sh but #!/bin/sh. And you are feeding the output into a new (Bourne, not Posix) shell. To use a posix shell you either have to export your path to /usr/xpg4/bin:$PATHor pipe your output to /usr/xpg4/bin/sh rather than sh
Last edited by Scrutinizer; 07-19-2016 at 03:55 AM..
This User Gave Thanks to Scrutinizer For This Post:
Hi All,
Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition.
#Body
function1()
{
if
then
echo "exist"
else
echo "not exist"
}
#if not exist in function1 my all other function will not proceed.... (4 Replies)
Hi,
I am having script which contains many functions. Need to print each function name at the starting of the function. Like below,
functionname()
{
echo "functionname"
commands....
}
I've tried like below,
func=`grep "()" scriptname | cut -d "(" -f1`
for i in $func
do
nawk -v... (4 Replies)
Dear All.
I have a script, which process files one by one. In the script I have two functions.
one sftp files to different server
the other from existing file create file with different name.
My question is:
Will sftp function recognize files names , which are created in another... (1 Reply)
I have a script which does gunzip, zip and untar.
Input to the script is file name and file directory (where file is located)
I am reading the input parameters as follows:
FILENAME=$1
FILEDIR=$2
I have created 3 functions that are as follows:
1) gunzip file
2) unzip file... (2 Replies)
Hi Gurus,
I have a requirment to use a function created in a script in another server within the script. Below is the sample script for reference
#/bin/bash
logs_gen () {
XXXXXXXXXXX
XXXXXXXXXXX
XXXXXXXXXXX
}
for i in x y z; do # x y z are the server... (7 Replies)
In gdb, I can call one function with command "call", but how can I step in the function? I don't want to restart the program, but the function had been executed, gdb will execute next statement, and I don't know how to recall the function. (4 Replies)
This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord
but only one record is getting wrote in DB.... Please advise ASAP...:confused:
function InsertFtg
{
FTGSTR=""
echo "Saurabh is GREAT $#"
let... (2 Replies)
Hi,
I have a question. I know that if I want to access any variables defined in a calling script (script1.ksh) in a called script (script2.ksh) I need to export that variable in the calling script to make it available in the called script. But what about the functions in the calling script?
... (1 Reply)
Hi ,
I have three funcions f1, f2 and f3 .
f1 calls f2 and f2 calls f3 .
I have a global variable "period" which i want to pass to f3 .
Can i pass the variable directly in the definition of f3 ?
Pls help .
sars (4 Replies)