03-01-2013
The usual approach is to put them either BEFORE the BEGIN rule, or AFTER the END rule. Performance-wise, it doesn't matter. You might want to have a look at
User-defined - The GNU Awk User's Guide
This User Gave Thanks to user8 For This Post:
10 More Discussions You Might Find Interesting
1. AIX
Hi,
I am just running a incremental back-up on one of my server.
But these days It abrubtly fails with below error.
==========
User defined signal 1
===========
When I rerun the back-up, It completed successfully.Earlier this was not happening.
Any Idea, what could be the problem... (0 Replies)
Discussion started by: nitesh_raj
0 Replies
2. Shell Programming and Scripting
I am working on a SunFire 480 - uname -a gives:
SunOS bsmdb02 5.9 Generic_112233-08 sun4u sparc SUNW,Sun-Fire-480R
I am tyring to sum up the total size of all the directories for each running database using awk:
#!/usr/bin/ksh
for Database in `ps -efl | grep "ora_pmon" | grep -v grep |... (1 Reply)
Discussion started by: jabberwocky
1 Replies
3. Shell Programming and Scripting
Hello Friends,
Is it possible to return an array from a user defined function in awk ?
example:
gawk '
BEGIN{}
{
catch_line = my_function(i)
print catch_line
print catch_line
print catch_line
}
function my_function(i)
{
print "echo"
line= "awk"
line= "gawk"... (2 Replies)
Discussion started by: user_prady
2 Replies
4. Shell Programming and Scripting
Imagine a user-defined function.
func() { /usr/pkg/bin/program long-string-of-switches-and-configs "$@" ;}
I execute it once. Then background it.
I execute another instance. Then bg it.
func unique-user-input
^Z
func unique-user-input
^Z
First I view with ps
ps wwaux
... (0 Replies)
Discussion started by: uiop44
0 Replies
5. Emergency UNIX and Linux Support
File: A.h
class A
{
public:
struct x X;
int show()
{
x.member_variable ? 0: -1;
}
};
Now if A.cpp is complied which includes A.h (which is actually in a huge project space) we see that x.member_variable value is not as expected. But if remove the show() method and place... (4 Replies)
Discussion started by: uunniixx
4 Replies
6. Shell Programming and Scripting
Hi;
Is der ne to to use user defined functions for the values in awk
find $1 -type f -ls | nawk '{{print "|"$3"|"$5"|"$6"|"$8"|"$9"|"$10"|"} for(i=11;i<=NF;i++){printf("%s",$i)}}'
In above command i want to append some values returned by user functions on line.
thnks;
ajay (1 Reply)
Discussion started by: ajaypadvi
1 Replies
7. Shell Programming and Scripting
Hi, guys,
The content of file is below (from <UNIX® Shells by Example Fourth Edition>):
My code is below:
gawk -F'' ' { OFS = "****"; $3 = "(904)"; $8 = $5 + $6 + $7; print } ' lab3.data
The result is below:
So, where is the $1? Why is the variable $8 located at the wired position? (3 Replies)
Discussion started by: franksunnn
3 Replies
8. UNIX for Dummies Questions & Answers
I have the variable defined in .bashrc
BIN_DIR="/usr/local/dw"
and in my shell script i am using below.
#!/bin/bash
echo "Bin Dir: ${BIN_DIR}"
. "${BIN_DIR}"/dwh_Loadfuncs.sh
Output:
Bin Dir:
/usr/local/dw/dwh_LoadXMLFileIntoStage.sh: line 7: /dwh_Loadfuncs.sh: No such file or... (3 Replies)
Discussion started by: Ariean
3 Replies
9. Shell Programming and Scripting
In the below script i found that the alias mkdir_s is getting invoked from function configure() i.e the alias is kicking in.
#!/bin/bash -e
shopt -s expand_aliases
alias mkdir=mkdir_s
mkdir_s(){
if ]; then
return
else
/usr/bin/mkdir "$1"
return
fi
}
configure()
{
mkdir -p... (9 Replies)
Discussion started by: mohtashims
9 Replies
10. UNIX for Beginners Questions & Answers
My requirement is to call function ("fun1") from awk, and print its returned value along with $0.
fun1()
{
t=$1
printf "%02d\n", $t % 60;
}
echo "Hi There 23" | awk '{print $0; system(fun1 $3)}'
Any suggestions what to be modified in above code to achieve requirement.. (5 Replies)
Discussion started by: JSKOBS
5 Replies