Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
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.
To be clear, the above would be inside a bash script which is called using "scriptname 5". You don't want to call the actual bash shell and pass "5" to it....my hunch is that bash would not know what to do....
but I believe I had a bug in my perl code. Nonetheless, does bash interpret a command line argument as a string or does it dynamically determine what it should be by what you do with it
say my command line argument was "happy" and "754", would bash know the first is a string and the second is a integer?
something like hexdump is handy for showing how things are stored. In Bash, numbers are stored as strings...the interpretation depends on what commands are used.
Brilliant! I had a look over the code you sent and believe I understand -- the context of what you do to the variable will define how it is classified by bash/perl, but for all intensive purposes, its originally stored as a string.
Brilliant! I had a look over the code you sent and believe I understand -- the context of what you do to the variable will define how it is classified by bash/perl, but for all intensive purposes, its originally stored as a string.
Yes but be careful, perl is a bit smarter and resourceful that bash. Perl has mathematical operations built into it, but bash will actually treat everything as a string by itself. You must use extra commands to get mathematical operations ('expr' and 'bc' come to mind). Those commands will interpret the variables as numbers and will fail if they are not.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.