Why do you need to do that? Pipe the result of the function to awk
Actually, awk output is the input for myFunk(). So I am not sure if this will do the trick.
This is the awk statement ->
This is the function ->
The function is required to check the array values (which are already in sequence now) and will print ' line type 1 ' and if not in sequence, then print ' line type 2 .' For example; if the array has following values - 20,21,22,23,25 - then it will print this:
If the values are not in sequence - 20, 22, 24 - then it will print this:
Best Regards..
Last edited by morningSunshine; 03-31-2010 at 11:05 AM..
That statement has an unmatched single quote, which is probably the reason for the sh giving an unexpected end of file error (it's looking for the end of a string when it hits end of file).
Aside from the quote, that's not a valid awk script. I would expect awk to abort with a syntax error. Is "action" a variable whose definition is omitted? Is "check" an awk user-defined funciton whose definition or inclusion you omitted? If so, you need to use parenthesis around its arguments:
If "action" and "check" are not a variable and user-defined function, respectively, then I have no clue what you're going for there.
Regarding myFunk(), I really hope that's csh. Otherwise, that sh/bash/ksh script needs a lot of work
That statement has an unmatched single quote, which is probably the reason for the sh giving an unexpected end of file error (it's looking for the end of a string when it hits end of file).
Aside from the quote, that's not a valid awk script. I would expect awk to abort with a syntax error. Is "action" a variable whose definition is omitted? Is "check" an awk user-defined funciton whose definition or inclusion you omitted? If so, you need to use parenthesis around its arguments:
If "action" and "check" are not a variable and user-defined function, respectively, then I have no clue what you're going for there.
Regarding myFunk(), I really hope that's csh. Otherwise, that sh/bash/ksh script needs a lot of work
Regards,
Alister
Hi Alister, sorry I was not clear about my earlier post. (check1, action1) were a sample text instead of the original script.
Here is the original script and function:
Update:
I have now been able to correct the syntax error from the script. Now upon executing the script, this error is appearing:
Quote:
awk: cmd. line:1: (FILENAME=c2.txt FNR=1) fatal: function `heybaby' not defined
Best Regards.
Last edited by morningSunshine; 03-31-2010 at 12:26 PM..
Reason: Updated the script / Syntax errors resolved
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,
I have the following code in which i am trying to find ceil of 10th & 11th fields. For finding ceil i have a function in the awk statement. When i test it for some values say on command line it gives correct response(say $10=0 & $11=750). But when the same value occurs in a file having more 3... (5 Replies)
In my prog if i enter the input for the 1st time it is executing correctly,
but for the second time entire script is not executing it just exiting
my code is
#!/bin/sh
checkpo()
{
echo "Checking the entered PO to create output text file ";
IFS=$'\n'
set -f
var=0
for i in $(cat... (3 Replies)
Hi,
I need to run start_load function for two tables.
Step 1: if HMAX_TBL_ID and GMAX_TBLI_D are same for tab_name1 then echo message "all table ids are processed"
Step 2: go back and call start_load for tab_name2 and check if table id are same for table 2 too.
Please let me know how to... (5 Replies)
Hi,
I have a shell script 'sample.sh' which has some functions as below.
#fun1
fun1()
{
date
}
#fun2()
{
echo hi
}
I want to run these functions as background processes and also redirect the output to a file. My function calling statements are in a different file 'sample.cfg' as... (3 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 had a scripts which calls two function. One function will call another function, script is working fine but the second function is not calling the first function. Below is the script
#!/usr/bin/ksh
fun1() {
echo $DATETIME >> Test1.ksh
return 0
}
fun2() {
typeset DATETIME=`date... (5 Replies)
Hi All,
My 1.txt contains some functions
fun1()
....
....
fun2()
....
....
I can call these fun from 2.txt inside awk as below
value="`fun1 "argument1"`"
awk 'BEGIN {printf ("%s", "'"$value"'")}'
I need to modify the above code so that without using the variable to store... (2 Replies)
I have created a file generic.func and it has lots of functions. One of the functions is this:
Check_backup_size()
{
dsmc q b $BACKUP_DIR/"*.Z" | awk '{print $1}'|sed 's///g' > outputfile
X=`awk '{sum += $1} END {print sum }' outputfile'`
echo "$X"
ls -ltr $BACKUP_DIR/"*.Z" | awk... (5 Replies)