cut

How do you pipe input through grep to another utility?

白昼怎懂夜的黑 提交于 2019-11-28 06:19:24
I am using 'tail -f' to follow a log file as it's updated; next I pipe the output of that to grep to show only the lines containing a search term ("org.springframework" in this case); finally I'd like to make is piping the output from grep to a third command, 'cut': tail -f logfile | grep org.springframework | cut -c 25- The cut command would remove the first 25 characters of each line for me if it could get the input from grep! (It works as expected if I eliminate 'grep' from the chain.) I'm using cygwin with bash. Actual results: When I add the second pipe to connect to the 'cut' command,

How can I find the minimum cut on a graph using a maximum flow algorithm?

瘦欲@ 提交于 2019-11-28 03:19:03
I need to find the minimum cut on a graph. I've been reading about flow networks, but all I can find are maximum flow algorithms such as Ford-Fulkerson, push-relabel, etc. Given the max flow-min cut theorem, is it possible to use one of those algorithms to find the minimum cut on a graph using a maximum flow algorithm? How? The best information I have found so far is that if I find "saturated" edges i.e. edges where flow equals capacity, those edges correspond to the minimum cut. Is that true? It doesn't sound 100% right to me. It is true that all edges on the minimum cut will be saturated,

Copy and paste content from one file to another file in vi

隐身守侯 提交于 2019-11-28 02:34:27
I am working with two files, I need to copy a few lines from one file and paste into another file. I know how to copy (yy) and paste(p) in the same file. But that doesn't work for different files, how is this done?? Also, is there a way to cut-paste? I have tried googling, but most of the resources only talk about copy-paste. Since you already know how to cut/yank text, here are a few ideas for pasting it back into another file: Edit the first file, yanking the text you want. Then open your second file from within vi ( :e /path/to/other/file ) and paste it Open both files together in a split

Printing only the first field in a string

守給你的承諾、 提交于 2019-11-27 22:42:52
I have a date as 12/12/2013 14:32 I want to convert it into only 12/12/2013 . The string can be 1/1/2013 12:32 or 1/10/2013 23:41 I need only the date part. You can do this easily with a variety of Unix tools: $ cut -d' ' -f1 <<< "12/12/2013 14:32" 12/12/2013 $ awk '{print $1}' <<< "12/12/2013 14:32" 12/12/2013 $ sed 's/ .*//' <<< "12/12/2013 14:32" 12/12/2013 $ grep -o "^\S\+" <<< "12/12/2013 14:32" 12/12/2013 $ perl -lane 'print $F[0]' <<< "12/12/2013 14:32" 12/12/2013 Suresh Anbarasan $ echo "12/12/2013 14:32" | awk '{print $1}' 12/12/2013 print $1 --> Prints first column of the supplied

How to cut the last field from a shell string

我的未来我决定 提交于 2019-11-27 20:56:44
问题 How to cut the last field in this shell string LINE="/string/to/cut.txt" So that the string would look like this LINE="/string/to/" Thanks in advance! 回答1: I think you could use the "dirname" command. It takes in input a file path, removes the filename part and returns the path. For example: $ dirname "/string/to/cut.txt" /string/to 回答2: For what it's worth, a cut -based solution: NEW_LINE="`echo "$LINE" | rev | cut -d/ -f2- | rev`/" 回答3: This will work in modern Bourne versions such as Dash,

How to strip out all of the links of an HTML file in Bash or grep or batch and store them in a text file

。_饼干妹妹 提交于 2019-11-27 19:10:27
I have a file that is HTML , and it has about 150 anchor tags. I need only the links from these tags, AKA, <a href="*http://www.google.com*"></a> . I want to get only the http://www.google.com part. When I run a grep, cat website.htm | grep -E '<a href=".*">' > links.txt this returns the entire line to me that it found on not the link I want, so I tried using a cut command: cat drawspace.txt | grep -E '<a href=".*">' | cut -d’”’ --output-delimiter=$'\n' > links.txt Except that it is wrong, and it doesn't work give me some error about wrong parameters... So I assume that the file was supposed

how to remove the first two columns in a file using shell (awk, sed, whatever)

早过忘川 提交于 2019-11-27 17:40:14
I have a file with many lines in each line there are many columns(fields) separated by blank " " the numbers of columns in each line are different I want to remove the first two columns how to? sampson-chen You can do it with cut : cut -d " " -f 3- input_filename > output_filename Explanation: cut : invoke the cut command -d " " : use a single space as the delimiter ( cut uses TAB by default) -f : specify fields to keep 3- : all the fields starting with field 3 input_filename : use this file as the input > output_filename : write the output to this file. Alternatively, you can do it with awk :

How to specify more spaces for the delimiter using cut?

雨燕双飞 提交于 2019-11-27 16:48:48
Is there any way to specify a field delimiter for more spaces with the cut command? (like " "+) ? For example: In the following string, I like to reach value '3744', what field delimiter I should say? $ps axu | grep jboss jboss 2574 0.0 0.0 3744 1092 ? S Aug17 0:00 /bin/sh /usr/java/jboss/bin/run.sh -c example.com -b 0.0.0.0 cut -d' ' is not what I want, for it's only for one single space. awk is not what I am looking for either, but how to do with 'cut'? thanks. Actually awk is exactly the tool you should be looking into: ps axu | grep '[j]boss' | awk '{print $5}' or you can ditch the grep

Using CUT and Quartile to generate breaks in R function

给你一囗甜甜゛ 提交于 2019-11-27 13:59:46
Following some great advice from before , I'm now writing my 2nd R function and using a similar logic. However, I'm trying to automate a bit more and may be getting too smart for my own good. I want to break the clients into quintiles based on the number of orders. Here's my code to do so: # sample data 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)) #function to break them into quintiles ApplyQuintiles <- function(x) { cut(x, breaks=c(quantile(df$orders, probs = seq(0, 1, by = 0.20))), labels=c("0-20

poj3253Fence Repair (Huffman)

不问归期 提交于 2019-11-27 13:08:41
Huffman树:具有n个外部节点(叶子节点)的二叉树 每个外部节点都有一个对应的权值Wi    叶节点带权外部路径长度总和WPL=Wi*Li(i从1到n)最小(权越大的节点里根越进) 构造Huffman树:1)根据给定的n个权值{W1,W2,W3......Wn}构成n棵二叉树的集合F={T1,T2,T3......Tn},其每棵二叉树只有一个权值为Wi的根节点 2)在F中取两棵根节点权值最小的树作为左右子树构造一棵新的二叉树,且令新二叉树的根节点的权值为左右子树根节点权值的和, 3)在F中删除这两棵树,同时将新得到的二叉树加入到几何中(其实只是让新二叉树的根节点的权值加入到集合中)         4)重复2)和3),直到F中只含一棵树为止。 2 4 5 7 四个数的Huffman树的构建: 也就是: 嗯嗯,也就是在专业课离散数学中学到的最优二叉树的构建过程 而Huffman树的一个典型应用是:计算最短前缀编码(一个字母的编码不是(任何)另一个编码的前缀的部分)。 用最优二叉树理解就是任何一个子节点都不是另一个子节点的祖先路径的一部分。 介绍完Huffman树,接下来就看看这道poj的题 Farmer John wants to repair a small length of the fence around the pasture. He measures the