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.
Thanks for the reply, Thats kind of what I was thinking, however I am still a little confused when trying to make this syntactically correct in Bash. Given the following:
1T,A,B1000
How would I express this constraint using bash (I want to start from 1)?
it seems I have it all wrong:
for $((1<=T;A;B<=1000; 1++))
do
something
done
or is it:
for ((T >= 1; T<= 1000; A >= 1; A <= 1000; B >=1; B <=1000; 1++ ))
do
something
done
(1) Use a real programming language. In Unix/Linux you have half-a-dozen (at least) to choose from, and many more are available at no cost. Through the magic of the #!shebang mechanism, any of these can be used to write "a shell command." The Korn shell is the only one which attempted to include a full-featured programming language as its shell-scripting tool.
(2) When you go about writing the thing, don't economize on source-code characters. For example, I think that the example above is unnecessarily terse. There's no advantage whatsoever in creating source code that a human must "puzzle out." There's also no advantage in saving microseconds. Especially in a "real" language, your source code will be efficiently translated into the actual instructions that the computer will execute.
(2-1/2) Liberally include comments in your code. Comments are free. They don't slow-down execution at all, even as they vastly increase readability and understanding.
Last edited by sundialsvcs; 09-07-2015 at 08:08 AM.
Thanks guys, for the great feedback. I now think I have a grasp (however faint) on setting these up. It is kind of how I thought. i.e. there is no short cut to expressing these constraints correctly.
I have spent a little time trying to learn python (which I guess is a real language), but have since put it on the back burner to try and improve my basic shell scripting..... It may take a while :-P
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.