cut

using Linux cut, sort and uniq

随声附和 提交于 2019-12-06 04:17:19
问题 I have a list with population, year, and county and I need to cut the list, and then find the number of uniq counties. The list starts off like this: #Population, Year, County 3900, 1969, Beaver 3798, 1970, Beaver 3830, 1971, Beaver 3864, 1972, Beaver 3993, 1973, Beaver 3976, 1974, Beaver 4064, 1975, Beaver There is much more to this list, and many more counties. I have to cut out the county column, sort it, and then output the number of uniq counties. I tried this command: cut -c3- list.txt

How do I format a Date field of a .CSV file with multiple commas in a string field

坚强是说给别人听的谎言 提交于 2019-12-06 02:43:27
I have a .CSV file (file.csv) whose data are all enclosed in double quotes. Sample format of the file is as below: column1,column2,column3,column4,column5,column6, column7, Column8, Column9, Column10 "12","B000QRIGJ4","4432","string with quotes, and with a comma, and colon: in between","4432","author1, name","890","88","11-OCT-11","12" "4432","B000QRIGJ4","890","another, string with quotes, and with more than, two commas: in between","455","author2, name","12","455","12-OCT-11","55" "11","B000QRIGJ4","77","string with, commas and (paranthesis) and : colans, in between","12","author3, name",

How to delete a column/columns of a CSV file which has cell values with a string enclosed in double quotes

我怕爱的太早我们不能终老 提交于 2019-12-05 13:28:42
How can I delete a column from a CSV file which has comma separated value with a string enclosed in double quotes and a comma in between? I have a file 44.csv with 4 lines including the header like the below format: column1, column2, column3, column 4, column5, column6 12,455,"string with quotes, and with a comma in between",4432,6787,890,88 4432,6787,"another, string with quotes, and with two comma in between",890,88,12,455 11,22,"simple string",77,777,333,22 I need to cut the 1,2,3 columns from the file, so I used the cut command as below cut -d"," -f1,2,3 44.csv > 444.csv I am getting the

How to slice/cut an image into pieces

人盡茶涼 提交于 2019-12-05 05:35:50
问题 So I have a function that receives OpenCV image and turns it into gray-scale. void UseLSD(IplImage* destination) { IplImage *destinationForGS = cvCreateImage(cvSize(destination->width, destination->height),IPL_DEPTH_8U,1); cvCvtColor(destination,destinationForGS,CV_RGB2GRAY); } How now to cut that image into images of size 10x10 pixels and iterate true them? (width and height may not divide on 10 but if there would be some loss (like loss from 1*h to 9*h+9*h pixels per image) it would be OK

Using cut in bash on a file with a unique deliminter

走远了吗. 提交于 2019-12-04 09:51:45
Can cut be used in bash with the ¬ delimiter? This question is an extension of the topic covered here . One interpretation of the goal in that link is to use a delimiter that can not be found (or very rarely found) in human text. Say we choose the 'Not Sign' ( ¬ ) as a delimiter. My question is regarding the use of cut to pull specific columns of a file with said delimiter. For example, say that we create a file with the ¬ delimiter. The file prac.txt might look like: $cat prac.txt "Billy""Car"¬"Red"¬"Garage"¬"3" "Rob"¬"Truck"¬"Blue"¬"Street"¬"14" The following process produces an error: $cut

using Linux cut, sort and uniq

。_饼干妹妹 提交于 2019-12-04 07:19:14
I have a list with population, year, and county and I need to cut the list, and then find the number of uniq counties. The list starts off like this: #Population, Year, County 3900, 1969, Beaver 3798, 1970, Beaver 3830, 1971, Beaver 3864, 1972, Beaver 3993, 1973, Beaver 3976, 1974, Beaver 4064, 1975, Beaver There is much more to this list, and many more counties. I have to cut out the county column, sort it, and then output the number of uniq counties. I tried this command: cut -c3- list.txt | sort -k3 | uniq -c But this does not cut the third list, nor does it sort it alphabetically. What am

Split file with 800,000 columns

女生的网名这么多〃 提交于 2019-12-04 04:35:42
问题 I want to split a file of genomic data with 800,000 columns and 40,000 rows into a series of files with 100 columns each, total size 118GB. I am currently running the following bash script, multithread 15 times: infile="$1" start=$2 end=$3 step=$(($4-1)) for((curr=$start, start=$start, end=$end; curr+step <= end; curr+=step+1)); do cut -f$curr-$((curr+step)) "$infile" > "${infile}.$curr" -d' ' done However, judging by current progress of the script, it will take 300 days to complete the split

Is it possible to use a string as a delimiter in unix cut command?

…衆ロ難τιáo~ 提交于 2019-12-03 15:33:11
问题 If I want to cut a list of text using a string as a delimiter, is that possible? For example I have a directory where a list of shell scripts call same perl script say abc.pl So when I do $grep abc.pl * in that directory, it gives me following results xyz.sh: abc.pl 1 2 xyz2.sh: abc.pl 2 mno.sh: abc.pl 3 pqr.sh: abc.pl 4 5 I basically want all the output after "abc.pl" (to check what range arguments are being passed to the perl right now) When I tried $grep abc.pl * | cut -d'abc.pl' -f2 OR

Is there a cleaner way of getting the last N characters of every line?

喜欢而已 提交于 2019-12-03 13:16:44
To simplify the discussion, let N = 3 . My current approach to extracting the last three characters of every line in a file or stream is to use sed to capture the last three characters in a group and replace the entire line with that group. sed 's/^.*\(.\{3\}\)/\1/' It works but it seems excessively verbose, especially when we compare to a method for getting the first three characters in a line. cut -c -3 Is there a cleaner way to extract the last N characters in every line? It's very simple with grep -o '...$' : cat /etc/passwd | grep -o '...$' ash /sh /sh /sh ync /sh /sh /sh Or better yer: N

How to cut part of a string in c?

孤人 提交于 2019-12-03 12:46:55
I'm trying to figure out how to cut part of a string in C. For example you have this character string "The dog died because a car hit him while it was crossing the road" how would a function go making the sentence "a car hit him while crossing the road" or "a car hit him" How do you go about this with C's library (or/and) a custom function? ok I don't have the main code but this is going to be the structure of this experiment #include <ctype.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <getopt.h> #include "display_usage.c"/*If the user enters wrong