>>Hi Jack,
HI > How can I read a file which contains a number and assign that number to > a variable via awk programming? By the way, I want to use this awk program > in a shell script. >>I'm actually not sure what you're asking, exactly -- you want the number >>to go into an awk variable? Or a shell variable? Yes, I want the number to go into an awk variable. >>Assuming you want it to go into an awk variable, I would try something >>like this: >> getline my_number < filename; >> close filename; >>That assumes the filename is stored in the variable named "filename". >>It puts the number in the awk variable named "my_number". >>To put that in context, let's say you're getting the filename from $0, >>and you want to multiply the number by 2 and print it. You might do: >> filename = $0; >> getline my_number < filename; >> close filename; >> print my_number * 2; >>Or if I completely misinterpreted your question, let me know :-) >> ~Ben This is what i wrote: #! /bin/sh filename=$0 awk 'getline no < filename; print no' But when I run this script sh /awk_no.sh /var/no.txt I have this error : awk: syntax error at source line 1 context is getline no < filename; >>> print <<< no awk: bailing out at source line 1 Thank you :) _______________________________________________ freebsd-questions@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-questions To unsubscribe, send any mail to "freebsd-questions-unsubscr...@freebsd.org"