cut

How do you pipe input through grep to another utility?

我的未来我决定 提交于 2019-11-27 01:16:48
问题 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

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

陌路散爱 提交于 2019-11-27 00:00:33
问题 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

Printing only the first field in a string

扶醉桌前 提交于 2019-11-26 23:12:44
问题 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. 回答1: 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 回答2: $ echo "12

Use space as a delimiter with cut command

牧云@^-^@ 提交于 2019-11-26 22:19:02
问题 I want to use space as a delimiter with the cut command. What syntax can I use for this? 回答1: cut -d ' ' -f 2 Where 2 is the field number of the space-delimited field you want. 回答2: Usually if you use space as delimiter, you want to treat multiple spaces as one, because you parse the output of a command aligning some columns with spaces. (and the google search for that lead me here) In this case a single cut command is not sufficient, and you need to use: tr -s ' ' | cut -d ' ' -f 2 Or awk '

How to get second last field from a cut command

自作多情 提交于 2019-11-26 19:27:44
问题 I have a set of data as input and need the second last field based on deleimiter. The lines may have different numbers of delimiter. How can I get second last field ? example input text,blah,blaah,foo this,is,another,text,line expected output blaah text 回答1: Got a hint from Unix cut except last two tokens and able to figure out the answer : cat datafile | rev | cut -d '/' -f 2 | rev 回答2: Awk is suited well for this: awk -F, '{print $(NF-1)}' file The variable NF is a special awk variable that

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

99封情书 提交于 2019-11-26 19:05:08
问题 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? 回答1: 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

How to specify more spaces for the delimiter using cut?

坚强是说给别人听的谎言 提交于 2019-11-26 18:45:49
问题 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. 回答1: Actually awk is exactly

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

假装没事ソ 提交于 2019-11-26 18:45:22
问题 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. 回答1: 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

Avoid Scientific notation in cut function in R

倾然丶 夕夏残阳落幕 提交于 2019-11-26 16:54:24
问题 How to avoid scientific notation present in the Intervals created by the cut function. a<-seq(10000,50000, by=500 ) cut(a, breaks = seq(0,max(a)+300, by = 300)) I have tried the below but it doesn't help. options("scipen"=100, "digits"=4) 回答1: As suggested by Pascal, Try with adding the argument dig.lab = 5 to cut function. 来源: https://stackoverflow.com/questions/29004620/avoid-scientific-notation-in-cut-function-in-r

How to make the &#39;cut&#39; command treat same sequental delimiters as one?

大憨熊 提交于 2019-11-26 13:59:41
I'm trying to extract a certain (the fourth) field from the column-based, 'space'-adjusted text stream. I'm trying to use the cut command in the following manner: cat text.txt | cut -d " " -f 4 Unfortunately, cut doesn't treat several spaces as one delimiter. I could have piped through awk awk '{ printf $4; }' or sed sed -E "s/[[:space:]]+/ /g" to collapse the spaces, but I'd like to know if there any way to deal with cut and several delimiters natively? kev Try: tr -s ' ' <text.txt | cut -d ' ' -f4 From the tr man page: -s, --squeeze-repeats replace each input sequence of a repeated character