09-22-2005
using awk to drive an internal function
I have a piece of script that needs to pull every element in column 2 from a file of varying size. Rather than writing something to read the file and then pass the data line by line to my script, I want to use awk.
However, what is the correct syntax to get awk to call a function (named via:
fcnname()
{
.
.
}
)
with the second column ($2), i.e. such as
awk '{fcnname($2)}' somefilename
I know I can do it from the command line or from yet another script and use the "system" command...and that is my next tack, but Id rather tie this all up in one pretty package.....
I have been playing with this syntax all day and not getting it right...
thanks
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi
I am trying to create a modify a txt file via a sh script and I'm not sure how to do it.
I have this:
data1a#data2a#data3aµ data1b#data2b#data3bµ data1c#data2c#data3cµ
and I want to have this (more or less)
data1a data2a data3a
data1b data2b data3b
data1c data2c data3c
I know... (5 Replies)
Discussion started by: Morgwen
5 Replies
2. AIX
Hi,
Help required!
How to mount internal tape drive of sun machine in AIX 5.3 (0 Replies)
Discussion started by: ashwin.krishna
0 Replies
3. UNIX for Advanced & Expert Users
Hi,
I need to redirect internal internet requests to a auth client site siting on the gateway. Currently users that are authenticated to access the internet have there mac address listed in the FORWARD chain. All other users need to be redirected to a internal site for authentication.
Can... (1 Reply)
Discussion started by: mshindo
1 Replies
4. Shell Programming and Scripting
Actually I got a list of file end with *.txt
I want to use the same command apply to all the *.txt
Thus I try to find out the fastest way to write those same command in a script and then want to let them run automatics.
For example:
I got the file below:
file1.txt
file2.txt
file3.txt... (4 Replies)
Discussion started by: patrick87
4 Replies
5. Shell Programming and Scripting
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
6. Shell Programming and Scripting
Hello,
When I run my awk script with input files greater than 300 MB I always get this error:
awk: Internal software error in the tostring function on TS1101?05044400?.0085498227?0?.0011041461?.0034752266?.00397045?0?0?0?0?0?0?11/02/10?09/23/10???10?no??0??no?sct_det3_10_20110516_143936.txt
... (0 Replies)
Discussion started by: script_op2a
0 Replies
7. Shell Programming and Scripting
Hello,
I posted a working script on this thread:
https://www.unix.com/emergency-unix-linux-support-help-me/160123-help-make-awk-script-more-efficient-large-files.html
When I run this script on a large file, 351 MB I get this error:
awk: Internal software error in the tostring function on... (8 Replies)
Discussion started by: script_op2a
8 Replies
8. Shell Programming and Scripting
Hello,
I am running a bash script under linux which first defines an CA-array like
j=0
num1=120.00
num2=10.00
until
do
CA='echo $num1 + $j*$num2'
j=$
done
within the later awk section of this same script I want to read data from a file. If the value of the second column is... (3 Replies)
Discussion started by: MotAah
3 Replies
9. Shell Programming and Scripting
Hi All,
I have a menu driven scripts. As you know while running the script we have to input the option such as 1,2, and 3 to execute function accordingly. but after selecting the input we have to press Enter.
My requirement is to execute function as soon as we press the option.
Is there... (5 Replies)
Discussion started by: kiran_j
5 Replies
10. Shell Programming and Scripting
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)
Discussion started by: Sumanthsv
4 Replies