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

Your last option works perfectly for me: $ cat > in.csv # Then pasted the example input followed by Ctrl+D: EXAMPLEfoo,60,6 EXAMPLEbar,30,6 EXAMPLE1,60,3 EXAMPLE2,120,6 EXAMPLE3,60,6 EXAMPLE4,30,6 [Ctrl+D] $ cat in.csv | cut -d, -f1 EXAMPLEfoo EXAMPLEbar EXAMPLE1 EXAMPLE2 EXAMPLE3 EXAMPLE4 Maybe line endings are biting you here? If the file has DOS-style or even old-Mac-style … Read more

cat, grep and cut – translated to python

You need to have better understanding of the python language and its standard library to translate the expression cat “$filename”: Reads the file cat “$filename” and dumps the content to stdout |: pipe redirects the stdout from previous command and feeds it to the stdin of the next command grep “something”: Searches the regular expressionsomething … Read more

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

From the source vertex, do a depth-first search along edges in the residual network (i.e., non-saturated edges and back edges of edges that have flow), and mark all vertices that can be reached this way. The cut consists of all edges that go from a marked to an unmarked vertex. Clearly, those edges are saturated … Read more

How to get first n characters of each line in unix data file

With cut: $ cut -c-22 file 0000000000011999980001 0000000000021999980001 0000000000031999980001 0000000000041999980001 0000000000051999980001 0000000000061999980001 If I understand the second requirement you want to split the first 22 characters into two columns of length 10 and 12. sed is the best choice for this: $ sed -r ‘s/(.{10})(.{12}).*/\1 \2/’ file 0000000000 011999980001 0000000000 021999980001 0000000000 031999980001 0000000000 041999980001 … Read more

Using ffmpeg to cut audio from/to position

With FFmpeg the ordering of parameters is significant. All of the parameters that come directly before an input will apply to that input. The same is true for an output… the parameters directly before it apply to the output. Consider this command line: ffmpeg -ss 132 -i input.mp3 output.mp3 -ss is the parameter to seek, … 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

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)