LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-06-2007, 08:02 AM   #1
jgrfilho
LQ Newbie
 
Registered: Dec 2007
Posts: 1

Rep: Reputation: 0
awk question about BEGIN patttern


I have a awk script with the following BEGIN pattern

BEGIN { upper = "PNBRQK"
lower = "pnbrqk"
getline < "lance1.tmp"
cor = substr($0,77,1)
}

I ca use cor inside other patterns when I run the script over lance1.tmp but I woul like to use it when I run the script over other files. How can I do that.

Thanks in advance for any help

Gaspar
 
Old 12-06-2007, 05:40 PM   #2
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
Use ARGV and ARGC

awk -f your-script.awk name-of-file-to-process

BEGIN { upper = "PNBRQK"
lower = "pnbrqk"
getline < ARGV[1]
cor = substr($0,77,1)
}

ARGV[0] contains "awk"

Use ARGC to see that you have two parameters, one for "awk" and one for your file name.
 
  


Reply

Tags
awk, begin



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
an awk question zoshr Programming 5 04-13-2007 05:29 AM
awk question davidkline Linux - General 9 09-29-2006 12:37 PM
Awk question blanny Linux - Software 6 05-02-2006 08:03 AM
AWK question paraiso Linux - Newbie 5 05-12-2005 01:37 PM
awk question jonlake Linux - Software 2 05-04-2005 03:58 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:47 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration