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
Extracting records with unique fields from a fixed width txt file sitney Shell Programming and Scripting 8 02-10-2008 03:18 AM
combining fields in two text fields shocker Shell Programming and Scripting 3 01-16-2008 11:27 AM
Extracting information from text fields. spindoctor UNIX for Dummies Questions & Answers 24 06-09-2007 01:17 PM
Cut Last 3 Fields bourne Shell Programming and Scripting 4 01-11-2007 05:17 AM
Extracting fields from an output 8-) csaha Shell Programming and Scripting 6 01-20-2006 08:37 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 10-08-2007
prvnrk prvnrk is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 138
extracting fields

Hi,

i have a line with several fields (indefinite number of - count varies) separated by colon.

Now, i need to pick each field (except the first one) and have it assigned to variable within a loop. In other words, in the first iteration of the loop, the variable must be assigned with 2nd field; In 2nd iteration, variable must be assigned with 3rd field and so on till the end of fields.

Any help would highly be appreciated.

TIA
Prvn
  #2 (permalink)  
Old 10-08-2007
Ygor's Avatar
Ygor Ygor is offline Forum Staff  
Moderator
  
 

Join Date: Oct 2003
Location: -31.96,115.84
Posts: 1,407
Here's an example using the $PATH variable...
Code:
oldIFS="$IFS"
IFS=":"
set $PATH
shift
for i
do
   echo do something with $i
done
IFS="$oldIFS"
  #3 (permalink)  
Old 10-08-2007
prvnrk prvnrk is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 138
Thanks Ygor,

It worked like a charm.

Thanks much
TIA
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 05:25 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