The tag has no usage guidance.

learn more… | top users | synonyms

0
votes
3answers
96 views

Compare a file with a column of another file

I have a file File1 with data as aaa bbb And another file File2 with data as: 2,aaa,234 w,bbb,589 4,ccc,675 I need to compare the File1 data with column2 data of File2 and print the matching ...
8
votes
8answers
19k views

Transposing rows and columns

I have a file with the lines like below. title1:A1 title2:A2 title3:A3 title4:A4 title5:A5 title1:B1 title2:B2 title3:B3 title4:B4 title5:B5 title1:C1 title2:C2 title3:C3 title4:C4 title5:C5 ...
4
votes
2answers
4k views

Select certain column of of each file, paste to a new file

I have 20 tab delimited files with the same number of rows. I want to select every 4th column of each file, pasted together to a new file. In the end, the new file will have 20 columns with each ...
1
vote
2answers
80 views

Adding new columns in a csv file

I want to append two new columns in the beginning of a csv file using bash scripting in a way such that the first four letters of the filename are the values of the first column and the next two ...
3
votes
2answers
26 views

Extract parts of csv filename in columns

I have a set of .csv files in a directory, say abc_q1_w1.csv defg_q11_w2.csv hijk_q11_w3.csv I want to write a script that extracts parts of the filename and put them in columns, i.e abc q1 ...
3
votes
2answers
158 views

`cut`: selecting columns containing a string

I have a big file with several columns on each line. I'm familiar with using cut -f -d to select specific columns by their number. I checked the manual for cut and it doesn't seem that there's a way ...
18
votes
3answers
22k views

Is there a simple command for outputting tab-delimited columns?

E.g. I have a file (produced with echo -e "var1\tvar2\t\var3\tvar4" > foo) that are output as: $ cat foo case elems meshing nlsys uniform 2350 0.076662 2.78 non-conformal 348 ...
0
votes
4answers
70 views

How to add hostname as first line of a file

I have a file which has a few lines. one two three four five I need to add hostname of the server I'm working on as the first line of the file. For example if abcd555.india.com is the server, the ...
2
votes
1answer
109 views

How to sort columns independently? [closed]

$ sort -t $'\t' -k 1rn,1 -k 2,2rn -k 3f,4 listaprezzi 2050 900 bananas 5 1905 700 grapes 17 250 4000 oranges 10 230 9200 ...
1
vote
3answers
64 views

How can I use a triple slash as a delimiter with cut?

I have a table in which each entry looks something like, coagulation factor VIII-associated 1 /// coagulation factor VIII-associated 2 /// coagulation factor VIII-associated 3 I would like to use ...
6
votes
4answers
75 views

True column deletion, not selecting all columns that you want

I know this is a simple question and in many ways has been answered before, however every use I've seen of awk, sed, grep etc have all been selecting and printing the columns you want. In a case where ...
1
vote
4answers
41 views

cut column 2 from text file

My text file has no delimiter to specify separator just spaces, how do I cut out column 2 to output file, 39 207 City and County of San Francisc REJECTED MAT = 0 78 412 Cases and ...
2
votes
1answer
44 views

How to standardize the number of characters in a column?

I have a column (in my data-file database) where the number of characters is not standardized, and need to standardize. How can I do it? Example: Sample_ID 159 148 1110 1100 150 But my bank does ...
0
votes
3answers
161 views

How to add a column if line contains string?

If I have a tab-delimited file containing the following lines: Sample1-Baboon 1 2 3 4 Sample2-Human 1 2 3 4 Sample3-Human 1 2 3 4 Sample4-Baboon 1 2 3 4 How can I add a new column ...
2
votes
3answers
173 views

Append a column

I've trawled through here and a few other places to try and find an answer to this, but it seems so stupidly simple that no one has answered it. All I need to do is add a single value in a new column ...
1
vote
1answer
19 views

Awk problem: an 'if column conditional' replaces the column entry!

I'm trying to get a grip on awk. Suppose I have an input: this header fred blah 1 blank fred blah 1 blank huh blah 2 blank fred blah 3 blank fred blah 3 blank and after I use the following awk ...
8
votes
3answers
30k views

print output to 3 separate columns

MYPATH=/var/www/html/error_logs/ TOTALFILE=$(ls $MYPATH* | wc -l) FILETIME=$(stat --format=%y $MYPATH* | head -5 | cut -d'.' -f1) FILE=$(ls -1tcr $MYPATH* | head -5 | rev | cut -d/ -f1 | rev) ...
3
votes
1answer
60 views

Combining every two column values in file

I have a file with (with only one line) with multiple columns say 4 (in this case) : A B C D And I want the output as every possible combination of column values taking 2 at a time like: AB AC AD ...
2
votes
2answers
42 views

average of specific rows in a file and output in tab-delimited file

I have 6 rows in files. I need to find average only of specific rows in a file and the others should be left as they are. The average should be calculated for A1 and A2, B1 and B2, other lines should ...
28
votes
2answers
9k views

How can I use column to delimit on tabs and not spaces?

I'd like to use Unix column to format some text. I have fields delimited by tabs, but within each field there are also spaces. column delimits on white space (tabs and spaces). How can I make column ...
0
votes
1answer
33 views

How to replace word in specific column if it does not match an expression?

I have the following file: chr1 157784 157887 U6 0 - chr1 564813 564881 miRNA 0 + chr1 564879 564950 tRNA 0 - chr1 564952 565019 tRNA 0 + chr1 566062 566129 ...
1
vote
2answers
47 views

Align command output in columns

I have the following output of my script: panos@panos:~/scripts> ./list_packages openSUSE-2016-254 zypper-aptitude.noarch : 1.12.23-1.1 update needed zypper-log.noarch : 1.12.23-1.1 update needed ...
1
vote
2answers
57 views

awk is putting last column in a new line

I have this -77.199997 23.6343749630 39.9989584580 -80.000000 23.6364583430 39.9989584580 -81.599998 23.6385417220 39.9989584580 I want to reorder the columns so it reads column 2, ...
4
votes
3answers
870 views

Removal of lines with no more or fewer than 'N' fields?

I am working on mac with sed, perl, awk, bash.. I have a large-ish (10GB) text file which has 13 fields (columns) of TAB delimited data. Unfortunately some of these lines have extraneous TABs , so I ...
5
votes
2answers
154 views

Issue with column command and color escape codes

I'm colorizing the header of a table formatted with column -ts $'\t' Works well without color codes, but when I add color codes to the first line column doesn't properly align the output. Without ...
2
votes
5answers
11k views

Sum the values in a column except the header

I have a file as given below -------------------------------------------------------------- Name_Customer Item_Purchased Item_Amount Credit ---------------------------------------------------------...
1
vote
1answer
46 views

Matching 2 main columns between files; and paste other columns into the output file when those main columns match. Keep row size of 1st file intact

This is a follow-up question to my previous question asked about 24 hours ago. Link to previous question: Previous Question Link G-Man solved that problem with a useful code, but I have a follow-up ...
3
votes
2answers
2k views

How do I insert new columns into a .csv file?

Example Data: "Monday","12345","Friday" In the above file, I want to add a new column in between 12345 and Friday. How can I do that ?
2
votes
1answer
97 views

Matching two main columns at the same time between files, and paste supplementary columns into the output file when those main columns match

I have 3 files, each with a unique number of columns, all tab-separated, but some columns are shared between the 3 files. It's the shared columns between the 3 files that I want to use to create some ...
0
votes
1answer
58 views

Sum values from column 1 if column 2 rows have a value match

I have data in a .txt like this: 2 40 1 50 1 50 1 50 1 50 2 70 2 70 5 80 5 80 6 100 And I want to sum first column if the second column's rows match so I can get an output like ...
1
vote
3answers
51 views

combine selected column multi file

I have multiple files (~15), each with multi column data (tab seperated). For example: File1 aa1 399 1815 aa2 1908 4064 aa3 4523 5656 File2 bb1 5304317 5305057 bb2 ...
1
vote
1answer
55 views

Merge records depending on common columns and specify the values which are uncommon in the last column as comma separated

I need to merge records depending on first three common columns and place the values which are uncommon in the last column as comma separated . I have a requirement to do the following- InputFile : ...
0
votes
1answer
15 views

Merge records depending on first three common columns and place the values which are uncommon in the last column as comma separated [duplicate]

Merge records depending on first three common columns and place the values which are uncommon in the last column as comma separated . I have a requirement to do the following- InputFile : HWF ...
1
vote
1answer
58 views

Comapring columns in 2 files and printing the values that differ

I have a file (file-1) that looks like this, DIP-10097N|refseq:NP_416170|uniprotkb:P30015 DIP-10117N|refseq:NP_414973|uniprotkb:P08177 DIP-10168N|refseq:NP_418766|uniprotkb:P15005 DIP-10199N|refseq:...
2
votes
3answers
115 views

Replace a column and preserve spacing

This is a follow up to unix: replace one entire column in one file with a single value from another file I am trying to replace one column of a file (file1) with one specific value from another file (...
1
vote
5answers
53 views

split the content of a specific column

I need to split the content of the second column of my file into 2 columns, for example: Id allele id2 30 TC 12 211 GG 12 327 AA 13 688 TC 15 760 TT 18 868 CC ...
3
votes
3answers
178 views

How do I create uniform columns from text containing both tabs and spaces?

In the simplest form, let's say I have an auto-generated file called file.txt. The contents of file.txt appears as follows: Source Destination Maximum To Maximum ...
6
votes
4answers
517 views

Delete column that includes a specific text

I was looking for an option to delete a column with a specific text like "ddd" aaa bbb ccc ddd eee fff 1 2 3 4 5 6 2 3 4 5 6 0 So that the output looks likes this: aaa bbb ccc ...
1
vote
1answer
99 views

Arrange data in columns

I have a big data.txt file like this: 6712,04444 6712,02344 6712,02220 6712,02233 5322,00040 5322,02230 5322,42002 4444,03342 4444,03323 11,42023 11,00000 11,23443 11,23232 and then I want to make ...
4
votes
2answers
233 views

Adding column based on matching of second column

I have two files. The first file has the following format: 10D0325 2465 0 0 -9 -9 10D0598 2567 0 0 -9 -9 10D0562 2673 0 0 -9 -9 10D0175 2457 0 0 -9 -9 10D0241 2209 0 0 -9 -9 10D0954 2312 0 0 -9 -9 ...
5
votes
2answers
101 views

Merging/Combining 2 text files according to numeric field

I have 2 text files file_1: 14595|Age 35|Salary xx|Position ax|2013|Info 1|Info 2|Info 3|Info 4|Info 5 14649|Age 30|Salary xx|Position az|2015|Info 1|Info 2|Info 3|Info 4|Info 5 file_2: 14595|...
6
votes
4answers
7k views

Compare two files: lines present in one, not in the other, by one column comparison

I need to compare 2 files. Column 1 is the same in both files. Column 2 is what I want to compare: I want all lines in file 1 that are not in file 2 when comparing column 2. Column 3 is different in ...
1
vote
3answers
127 views

Remove comma from columns in a file if it is at the end

I have a tab separated file contain 19 columns, some of these columns contain comma at the end. I want to removed these comma from all columns if it is at the end. Example: c1 c2 c3 c4 c5 ...
3
votes
3answers
1k views

Merging content of two files with comparing content of column

I have a problem trying to merge content of two files : file 1 : 873 1.1.1.1 1033 99.99.99.10 1108 78.2.204.174 1257 78.2.8.181 file 2: test1 78.2.8.181 p6 test2 99.99.99.10 p9 test7 1.1.1.1 ...
4
votes
1answer
2k views

merge csv files by first column

I have 3 csv files like this. csv 1: 1,aaaa,bbb,2014-04-01 2,qwe,rty,2014-04-03 3,zxc,cvb,2014-04-05 csv 2: 2,j,k,2014-04-01 3,a,s,2014-04-04 5,g,h,2014-04-08 csv 3: 2,a,s,d,f,g,2014-04-01 3,...
7
votes
5answers
3k views

A better paste command

I have the following two files ( I padded the lines with dots so every line in a file is the same width and made file1 all caps to make it more clear). contents of file1: ETIAM...... SED........ ...
2
votes
1answer
124 views

Add/Append a column as first column to a tab delimited file

I have a Tab separated file as follows: A B HM 1 BN 2 I would like to add another column to this file such that this new column becomes the first column of the file as shown below: ...
1
vote
1answer
195 views

How to extract unique values within columns

I have a data file with 10,000 columns and 117,000 rows. my original data has a lot of repetition within each columns. it is like: inputfile.txt : 123 124 111 321 124 111 123 000 111 ...
3
votes
2answers
3k views

Print some fields of /etc/passwd

I have a question concerning the usage of wild cards in Linux. Here I have some lines from a long list of lines in the /etc/passwd -file. root:x:0:0:root:/root:/bin/bash daemon:x:1:1:daemon:/usr/...
1
vote
5answers
223 views

lines to columns with awk

I have to following sample output: <HARDWARE> <NAME>WIN1</NAME> <OS>Windows 7</OS> <IP>1.2.3.4</IP> <DOMAIN>contoso.com</DOMAIN> &...