Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

newbie question:extract last argument in a line when number of arguments is unknown
Hi,

I need to extract the last argument of a given line, when number of
arguments in line is unkown.

Is there a way for doing it in a single awk command?
How can it be done generally? (without the one command limitation)

Any help would be appreciated,

thanks,
yaniv

Report this thread to moderator Post Follow-up to this message
Old Post
yaniv
03-20-04 01:23 AM


Re: newbie question:extract last argument in a line when number of arguments is unknown
In article <d742ebad.0402240203.46836e43@posting.google.com>,
yaniv <valiky@hotmail.com> wrote:

% I need to extract the last argument of a given line, when number of
% arguments in line is unkown.

You might want to give an example of what you hope to achieve. Given
this:

awk -f somefile.awk here are some arguments

there's a variable called ARGC which will be set to 5 and an array
called ARGV. ARGV[1] will be set to "here", ..., ARGV[4] will be
set to "arguments". ARGV[4] is the same as ARGV[ARGC-1].

On some systems, this will not work. The reason is that awk on those systems
s the original, pre-1987 awk, while the language discussed in this group
is invoked using the name nawk. The only widely used system with this
characteristic is Solaris, and you can fix it by setting the path
appropriately (to start with /usr/xpg4/bin).

--

Patrick TJ McPhee
East York  Canada
ptjm@interlog.com

Report this thread to moderator Post Follow-up to this message
Old Post
Patrick TJ McPhee
03-20-04 01:23 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

AWK archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:30 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.