cut

Cut and labels/breaks length conflict

爱⌒轻易说出口 提交于 2019-11-29 09:32:52
I am working with the cut function to prep data for a barplot histogram but keep running into a seeming inconsistency between my labels and breaks: Error in cut.default(sample(1:1e+05, 500, T), breaks = sq, labels = sprintf("$%.0f", : labels/breaks length conflict Here is an example. I pretend that it is income data, using a sequence of 0 to $100,000 in bins of $10,000. I use the same variable to generate both breaks and labels, with minor formating on the label side. I thought they might for some reason have different lengths when comparing to a character vector, but they appear to have the

tail -f into grep into cut not working properly

爷,独闯天下 提交于 2019-11-29 05:38:30
i'm trying to build a shell script to monitor some log files. I'm using a command like this: tail -f /var/somelog | grep --line-buffered " some test and p l a c e h o l d e r" | cut -f 3,4,14 -d " " the log file is like: some test and p l a c e h o l d e r 3 some test and p l a c e h o l d e r 4 some test and p l a c e h o l d e r 5 some test and p l a c e h o l d e r 6 and so on.. My issue is that the output of the command does not display the last line some test and p l a c e h o l d e r 6 until line some test and p l a c e h o l d e r 7 is added to the log. I hope I made clear my issue. Can

How to use cut with multiple character delimiter? unix

て烟熏妆下的殇ゞ 提交于 2019-11-29 05:22:59
问题 My file looks like this abc ||| xyz ||| foo bar hello world ||| spam ham jam ||| blah blah I want to extract a specific column, e.g. I could have done: sed 's/\s|||\s/\\t/g' file | cut -f1 But is there other way of doing that? 回答1: Since | is a valid regex expression, it need to be escaped \\| or put in square brackets [|] You can do this: awk -F' \\|\\|\\| ' '{print $1}' file Some other variation that work as well awk -F' [|][|][|] ' '{print "$1"}' file awk -F' [|]{3} ' '{print "$1"}' file

Parsing the first column of a csv file to a new file

*爱你&永不变心* 提交于 2019-11-28 21:09:16
Operating System: OSX Method: From the command line, so using sed, cut, gawk, although preferably no installing modules. Essentially I am trying to take the first column of a csv file and parse it to a new file. Example input file EXAMPLEfoo,60,6 EXAMPLEbar,30,6 EXAMPLE1,60,3 EXAMPLE2,120,6 EXAMPLE3,60,6 EXAMPLE4,30,6 Desire output EXAMPLEfoo EXAMPLEbar EXAMPLE1 EXAMPLE2 EXAMPLE3 EXAMPLE4 So I want the first column. Here is what I have tried so far: awk -F"," '{print $1}' in.csv > out.txt awk -F"," '{for (i=2;i<=NF;i++)}' in.csv > out.txt awk -F"," 'BEGIN { OFS="," }' '{print $1}' in.csv > out

Get free disk space with df to just display free space in kb?

半世苍凉 提交于 2019-11-28 20:21:45
I'm trying to output the amount of free disk space on the filesystem /example . If I run the command df -k /example I can get good information about available disk space in kb but only by being human and actually looking at it. I need to take this data and use it somewhere else in my shell script. I initially thought about using cut but then my script wont be portable to other disks as free disk space will vary and cut will not produce accurate results. How can I get output of just the free disk-space of example in kb? fedorqui To get the output of df to display the data in kb you just need to

Print Field 'N' to End of Line

微笑、不失礼 提交于 2019-11-28 14:17:22
I would like to have help or direction on a problem I have in awk. I have a tab-delimited file with more than 5 fields. I want to output the fields excluding the first 5 fields. Could you please tell how to write an awk script to accomplish this task? Best, jianfeng.mao Do Note the following kind comment: There are many fields in my files. Different lines have a different number of fields. The number of fields per line is not standard. I agree with matchew's suggestion to use cut : it's the right tool for this job. But if this is just going to become a part of a larger awk script, here's how

Error using t.test() in R - not enough 'y' observations

江枫思渺然 提交于 2019-11-28 13:58:04
I got this error for my code Error in t.test.default(dat$Value, x[[i]][[2]]) : not enough 'y' observations I think the reason I got this error is because I'm doing a t.test for data that only has one value (so there wouldnt be a mean or an sd) vs data that has 20 values..is there a way I can get around this.. is there a way I can ignore the data that doesn't have enough y observations??? like an if loop might work...pls help So my code that does the t.test is t<- lapply(1:length(x), function(i) t.test(dat$Value,x[[i]][[2]])) where x is data in the form of cuts similar to cut: [3:8) Number

swift: how to delete part of audio?

南笙酒味 提交于 2019-11-28 13:02:52
I'm creating a simple audio editing tool to trim and delete from an audio. I implemented the trim function and it is working fine. However I searched and tried to implement the delete function and here is my code: func deleteExportAsset(_ asset: AVAsset, fileName: String, completeAudioTime: CGFloat) -> URL { print("\(#function)") let documentsDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] let trimmedSoundFileURL = documentsDirectory.appendingPathComponent(fileName) print("saving to \(trimmedSoundFileURL.absoluteString)") if FileManager.default.fileExists

Get java version number from python

前提是你 提交于 2019-11-28 12:40:48
I need to get the java version number, for example "1.5", from python (or bash). I would use: os.system('java -version 2>&1 | grep "java version" | cut -d "\\\"" -f 2') But that returns 1.5.0_30 It needs to be compatible if the number changes to "1.10" for example. I would like to use cut or grep or even sed. It should be in one line. Considering an output like this: $ java -version java version "1.8.0_25" Java(TM) SE Runtime Environment (build 1.8.0_25-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode) You can get the version number with awk like this: $ java -version 2>&1 |

Extracting breakpoints with intervals closed on the left

六眼飞鱼酱① 提交于 2019-11-28 09:43:43
问题 I'm looking at the example menu of the command cut() ( example(cut) ), specifically this part: cut> aaa <- c(1,2,3,4,5,2,3,4,5,6,7) cut> cut(aaa, 3) [1] (0.994,3] (0.994,3] (3,5] (3,5] (3,5] (0.994,3] [7] (3,5] (3,5] (3,5] (5,7.01] (5,7.01] Levels: (0.994,3] (3,5] (5,7.01] cut> cut(aaa, 3, dig.lab = 4, ordered = TRUE) [1] (0.994,2.998] (0.994,2.998] (2.998,5.002] (2.998,5.002] [5] (2.998,5.002] (0.994,2.998] (2.998,5.002] (2.998,5.002] [9] (2.998,5.002] (5.002,7.006] (5.002,7.006] Levels: (0