The UNIX and Linux Forums  


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



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

Reply
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-14-2009
Registered User
 

Join Date: Jul 2009
Posts: 4
Extracting field from array

I have a problem with the following lines of code:

Code:
        SaveIFS=$IFS
        IFS="/"
        declare -a Array=($1)#take unix path, split by '/'
        website=${Array[4]} #stores website name

The confusing part is that it works on one machine, but not on the other.

If the code is moved to another machine, I get empty string instead of website (the path is identical on both machines).
  #2 (permalink)  
Old 11-14-2009
fpmurphy's Avatar
Moderator
 

Join Date: Dec 2003
Location: Florida
Posts: 2,030
Are you using the same shell on both machines?
  #3 (permalink)  
Old 11-17-2009
Registered User
 

Join Date: Jul 2009
Posts: 4
It appeared to be different shell versions. The was a bug in the older one. Upgrading the shell fixed it. Thanks!
Sponsored Links
Reply

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 Off


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Problem adding into an array field!!! talk2pawee Shell Programming and Scripting 5 06-11-2009 03:39 AM
Extracting a field value from a line Naresh Akkal Shell Programming and Scripting 5 05-06-2009 04:51 AM
Extracting Field values for XML file junaid.nehvi High Level Programming 3 03-27-2009 12:38 PM
Perl - if conditions is meet, push the last field of $_ into an array popeye Shell Programming and Scripting 1 12-10-2008 02:16 PM
extracting a field from directory path ?????? skyineyes Shell Programming and Scripting 15 07-10-2007 01:42 AM



All times are GMT -4. The time now is 01:41 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