LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-04-2005, 01:47 PM   #1
neidias
LQ Newbie
 
Registered: Apr 2005
Posts: 1

Rep: Reputation: 0
shell: positional parameters...


Hi

I need to display the sequential number of a word in a file.
Example

# cat test_file
orange Gremio Linux Gates Brazil
#

In this case, Orange is 1, Gremio is 2, Linux 3 etc....

other file...

# cat test_file2
Gremio Samba Bush orange Brazil
#

Now Gremio is 1, Samba is 2, Bush is 3 etc...

I'm trying to read a line, set the first word after other specific word like an argument.
In examples above, Gremio is the specific word.
In first file the word "Linux" is parameter;
In the second the word "Samba" is parameters;

tanks for any kind of help...
 
Old 04-04-2005, 02:45 PM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
try awk like this:
Code:
   
   awk '
   {
       i=1
       while( $i != "Gremio") 
       {
           i++;
       }  
       shift = i
       i++;       
       while(i< NF)
       {
          print i-shift, $i;
          i++;
       }
   }  '  test_file
 
  


Reply



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
Passing parameters to a shell script neocookie Linux - General 5 10-20-2005 11:44 AM
Positional Parameters (arguments) desbyleo Solaris / OpenSolaris 2 10-25-2004 11:51 AM
positional parameters $1 $2 in sed command Warmduvet Programming 12 09-22-2004 03:56 PM
Help with positional parameters Read_Icculus Linux - General 7 11-02-2003 04:23 AM
pass parameters to shell scripts ? qwijibow Linux - Newbie 2 08-07-2003 07:27 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:15 PM.

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