Why does cygwin and linux give different array outputs?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Why does cygwin and linux give different array outputs?
Hi,
I have written a script which works in cygwin (CYGWIN_NT-6.1-WOW64 1.7.11(0.260/5/3)) but i know want to run it on lunix (Linux 2.6.18-53.1.21.el5 #1 SMP Tue May 20 09:35:07 EDT 2008).
The script which works in cygwin does not work in linux. After some investigation I have found it to be due to array issues, so i wrote a simpel test script:
Can any one explain to me why this script does not give the same output in both? Also, and more importantly, is there any way to make the linux output the same as the cygwin one? or do i have to go and make some significant edits to my origional cygwin script.
A sample of the file "$PART_NAME"_2D_ELSET.tmp is below:
I'm not a scripting expert, however I did take the script and data that you posted to see if I could recreate the problem you have described. The output generated under both Ubuntu 10.04 and Kubuntu 12.04 were the same as you described for cygwin.
Last edited by dwhitney67; 08-08-2012 at 01:52 PM.
As Kenhelm says, it seems to be that cygwin can deal with a space in front to the first character, where as linux can not. i'm not sure why. It may just be the versions of bash i'm using.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.