In shell code you are concerned about: efficiency and readability
The former because you want to minimize the impact of your code on the system, the latter because you and others will have to change this stuff X years from now when you have completely forgotten about it, and it no longer works the way you need.
Either of these is equally fast:
The first one is more conventional, and is more likely to port.
[ is a bash builtin, [[ is a keyword so they both run as part of the shell, as does (( )).
So it boils down to which one is the easiest to for another person to interpret, which is a personal matter.
This User Gave Thanks to jim mcnamara For This Post:
I have the following code and into into trying to simplifying it. Any suggestions please?
pmin = min (p(1), p(2), p(3), p(4), p(5), p(6))
ni = 0
xint = 0.0
yint = 0.0
zint = 0.0
!--------------------------------------------- !
if ((0.99999 * p(1)) <= pmin) then
... (3 Replies)
Hi All,
I have a file menu_opts is as follows
# cat menu_opts
Please select the options
qqqq_usb STD RETAIL Progs (Prime time cue advertisements)
qqqq_onc STD Dealer Progs (Prime time cue advertisements)
qqqq_zt_usb STD RETAIL Progs (Long Format cue... (2 Replies)
hey,
I have text file which has some data for some device Id's. i want to perform AVG, MAX,2nd MAX on these device ids. The .txt file looks like below. please help me in finding the computations per Device id. My output file should contatin with DeviceID,Avg, max and 2nd max of the device ID.... (8 Replies)
Hi,
I'm quite new to scripting, but know a few AWK statements.
I have the following line in my script:
hostname=`echo $file | awk 'BEGIN{FS=OFS="."}{$NF=""; NF--; print}'`
I use this in my script to rename files, which are similar to this:
name.mvkf.mkvfm.mkfvm.1
To the... (4 Replies)
Can someone tell me how to change the first column in a very large 17k line file from a random 10 digit numeric value to a non numeric value. The format of lines in the file is:
1702938475,SNU022,201004
the first 10 numbers always begin with 170 (6 Replies)
Is there an easy way using a command or other routine for testing whether an argument on the command line is numeric? Just want to validate... I ran a search and didn't find a similar question....
Thx (3 Replies)
I am trying to setup to automatically import a series of mysql database files. I am doing manually now and its a royal pain.
All the sql files are sequentially numbered in a format of 4 numbers underscore text with spaces replaced by underscores.
example:
There are 3 databases each setup... (1 Reply)
Hello folks,
I have data collected in every 3 hours. But, I would like to expand this to 1 hour interval by equally dividing with next row.
For example, I want to keep the first value 1987-01-01-00z 2.0, but following all record should be re-written as follow.
1987-01-01-03z 5.0 becomes... (11 Replies)