The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
no options nascimento.rp AIX 2 08-20-2006 02:46 PM
options terms5 UNIX for Dummies Questions & Answers 1 01-27-2006 01:50 AM
sed h and g options sivasenthil_k Shell Programming and Scripting 9 01-04-2006 09:21 AM
cat and wc options Laura01 Shell Programming and Scripting 1 09-08-2002 11:21 PM
cp options milage UNIX for Dummies Questions & Answers 3 07-13-2001 12:20 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-11-2004
mips mips is offline
Registered User
  
 

Join Date: Apr 2004
Posts: 11
options with awk

Hi everybody,
I have some difficulties to use awk with the right options (as always): i have for example 3 fields:
IF-MIB::ifIndex.1
IF-MIB::ifIndex.2
IF-MIB::ifIndex.3
i want to use "while" to access to these records one by one
so i wrote this script but it didn t return the right value:

(small script which returns the 3 records) | awk 'BEGIN {FS="\n"} { i=1
while (i<4)
{ print $i
i++
}
}'

this returns me all records wheras i want only the first or the second (for example)
which corrections may i do to allow me to access to the right record
Thank you for you help
  #2 (permalink)  
Old 05-11-2004
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
Not sure that I understand the question (or even what the while loop is for) but if you want to return the second record then just use...

(small script which returns the 3 records) | awk NR==2
  #3 (permalink)  
Old 05-15-2004
home_king home_king is offline
Registered User
  
 

Join Date: Apr 2004
Location: China
Posts: 15
"Process the file line by line" is just the function of awk!
I think you must go over it.

FS="\n", such statement is used just when you want to process file paragraph by paragraph. It may formatted as below:
---------------------------------
#para1 as $1
hihi
king is a good boy.
I am home_king.

#para2 as $2
I am the east of the end.
Welcome to linuxsir.org
----------------------------------
then you can state that BEGIN{FS="\n",RS=""} :-)

Don't modify FS carelessly. By default, FS=[ \t].
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:50 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0