Get java version number from python

The Java runtime seems to send the version information to the stderr. You can get at this using Python’s subprocess module: >>> import subprocess >>> version = subprocess.check_output([‘java’, ‘-version’], stderr=subprocess.STDOUT) >>> print version java version “1.7.0_79” Java(TM) SE Runtime Environment (build 1.7.0_79-b15) Java HotSpot(TM) Client VM (build 24.79-b02, mixed mode) You can get the version … Read more

Using cut command to remove multiple columns

You should be able to continue the sequences directly in your existing -f specification. To skip both 5 and 7, try: cut -d, -f-4,6-6,8- As you’re skipping a single sequential column, this can also be written as: cut -d, -f-4,6,8- To keep it going, if you wanted to skip 5, 7, and 11, you would … Read more

Using CUT and Quartile to generate breaks in R function

Try the following: set.seed(700) clientID <- round(runif(200,min=2000, max=3000),0) orders <- round(runif(200,min=1, max=50),0) df <- df <- data.frame(cbind(clientID,orders)) ApplyQuintiles <- function(x) { cut(x, breaks=c(quantile(df$orders, probs = seq(0, 1, by = 0.20))), labels=c(“0-20″,”20-40″,”40-60″,”60-80″,”80-100”), include.lowest=TRUE) } df$Quintile <- sapply(df$orders, ApplyQuintiles) table(df$Quintile) 0-20 20-40 40-60 60-80 80-100 40 41 39 40 40 I included include.lowest=TRUE in your cut function, … Read more

Rearrange columns using cut

For the cut(1) man page: Use one, and only one of -b, -c or -f. Each LIST is made up of one range, or many ranges separated by commas. Selected input is written in the same order that it is read, and is written exactly once. It reaches field 1 first, so that is printed, … Read more

How to find the last field using ‘cut’

You could try something like this: echo ‘maps.google.com’ | rev | cut -d’.’ -f 1 | rev Explanation rev reverses “maps.google.com” to be moc.elgoog.spam cut uses dot (ie ‘.’) as the delimiter, and chooses the first field, which is moc lastly, we reverse it again to get com