I have a shell script where a lot of the code is repeated. I wanted to make the code much more compact so I spoke to a guy and he suggested using arrays, like follows:
I like this, because not only is the code nice and short, but it stops repetition where operations are similar, for example downloading files.
It looks pretty, but I wouldn't call it organized. You've got lots of data duplication -- why bother storing nginx in an array named nginx -- and if both things get the same prefix and make options, why not split that out too? And you're not looping things you can loop. And you're desperately avoiding splitting when it's something that could replace 80% of your code here. And using arrays means you end up spitting out ${ARR[1]} and ${ARR[2]} everywhere instead of using meaningful variable names. Why is '-j 4' the third element of your array and not the second, fifth, ninth? Only the original programmer knows.
In short this code will be as hard for you to read later as it was for me to read now.
I'd still split the URL's out since they're big and unwieldy.
I suppose you could have variables overriding the default $CONFIG_OPTS and $MAKE_OPTS for a particular package. If they're blank, use the default options, if they're not, use them instead.
Last edited by Corona688; 07-24-2012 at 12:22 PM..
Hi all, I now have project in UNIX Solaris and I want to have some new ideas to execute it, so I hope you help me finding new ideas in scripting or some infrastructure .bye (1 Reply)
Hi folks.
I work with several production servers, and I have seen in some Kernel Cache using most of the memory.
See this pic:
http://i51.tinypic.com/301nb6c.jpg
Do you think this is a smart choice? Remember these are productions servers and it is extremely necesary this does not... (6 Replies)
Hello friends,
I need an idea or a ready solution for a problem
i have the following lines in text file:
1 20100920140122 object4 MOVE IN
2 20100920150012 object4 MOVE OUT
-- cut --
the second column is the date and time:
20100920140122 = 2010 09 20 14:01.22
what I need to do is to add 40... (8 Replies)
Hello Group,
Could you please help me with a shell script that condense in this case each 12 rows of hour information in only one row per day as following:
Final Fields in each row
1.Ticker Name
2. D (Daily)
3. Date
4. Open Price (The open price of the first record of the day)
5. High... (13 Replies)
Hi there, I'm pretty new to scripting and wondering if anyone had any idea's, scripts or snippets on how I can do the following.
I basically want a shell script that will look at all the files in a directory and find all the names and addresses in them then output them to the screen nicely... (12 Replies)
txt file like this,
1 2 3 4456
a bb c d 3 f e
1 k 32 d m f e
123 m 2 k
every line contains 3 or more columns, all the columns are separated by space, and every column includes 1 to 3 character.
what I wanna do is deleting the first three columns, and keep the rest no matter how long... (7 Replies)
Keeping in mind that I'm relatively comfortable with programming in general but very new to unix and korn/bourne shell scripts..
I'm using awk on a CSV file, and then performing calculations and operations on specific fields within specific records. The CSV file I'm working with has about 600... (2 Replies)
I was just wondering if it would be alright to dual boot a machine with both UNIX using XTERM for the interface and windows 98 or if people consider this a bad idea? if you consider it bad do tell me some possible alternatives..also would it be better to get linux over pure unix? I'd like a visual... (8 Replies)