Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [columns]

Use this tag when describing a specific portion of a particular group of entries in a table or a matrix or any other structured data set which is vertically aligned.

1
vote
2answers
39 views

How to generate a pivotal table?

I have a file which looks like this: latitude Chr01 0.85 latitude Chr05 0.25 latitude Chr11 0.07 latitude Chr13_a 0.26 latitude Chr13_b 0.00 latitude Chr14_a 0.00 latitude Chr14_b 1 latitude Chr15 1 ...
1
vote
1answer
24 views

Print table with empty columns for consecutive delimiters

I typically use column to convert input into a table, eg: $ echo 'a\tb\tc\nd\te\tf' | column -t -s $'\t' a b c d e f However it collapses empty columns eg: $ echo 'a\tb\tc\nd\t\tf' | column -t -...
0
votes
1answer
41 views

Find, grep and then create table

I am trying to find all *.md at ${PWD}, then grep for lines beginning with title: and print it along with the absolute filepath -H and the line number of the pattern match -n, then I try to output the ...
4
votes
1answer
131 views

Sort multiple delimited file lexicographically by one column, numerically by another

I wish to sort the TSV file below (called min_ex) by the first column lexicographically and by the second column numerically. A X, N 2.2 A, N 5.7 A, A 5.8 A, N 2.1 A, T 0.2 B G, M 2....
0
votes
3answers
43 views

Get a certain column of an output with content aligned right and some columns not always filled

This is a problem I often encounter, this time with the output of lsof, but I am searching for a general solution for such problems: selecting a column. Here I try to get the TYPE column of the ...
2
votes
3answers
42 views

Split content of specific columns when specific characters are present in those columns

I have this data tab delimited: ed00011 89 0.12 NA NA No ed0002s 28 0.11 c3(3.1e-1) NA No ed0001 22 0.37 NA ...
1
vote
2answers
60 views

How do I align columns at common elements but give differing elements their own rows?

I am using paste to merge three text files (which do not require sorting) into a single document with three columns. paste a.txt b.txt c.txt I'd like elements that the columns have in common to ...
0
votes
1answer
65 views

To compare column1 of two files

I need to compare the column 1 of file 1 with the column 1 of file2 in my script, if the column 1 of file1 matches with the column 1 of file2, then only it should proceed further ,else exit. I'm with ...
1
vote
2answers
35 views

Printing a file in columns with arbitrary amount of rows

I have this file: line1 line2 line3 line4 line5 line6 line7 line8 line9 And I want to print it across 3 columns with this structure so that first column has lines 1-2-3, second column has the lines ...
3
votes
4answers
621 views

cut / grep df -h [duplicate]

How can I get the mount point "3.1T" under the column " Avail" (using grep or cut)? Filesystem Size Used Avail Use% Mounted on vstorage://cluster07 4.0T ...
2
votes
2answers
361 views

Calling an array inside awk to create a table with fixed-width columns

I would like to extract data from a file and organize it in a big fixed-widths table. I can expect that this table will have multiple columns, let's say 30 columns. If I create this table using the ...
1
vote
1answer
237 views

Switch columns in CSV using awk? [duplicate]

I have the exact same question as this one here. Only difference is I have 3 columns only and I am trying to move the 1st column to the end. The original file looks like this: col1,col2,col3 2,2015-...
0
votes
0answers
32 views

Can coreutils' `pr` do what util-linux's `column` can do?

Can coreutils' pr do what util-linux's column can do: The column utility formats its input into multiple columns. The util support three modes: columns are filled before rows ...
0
votes
2answers
71 views

Remove and replace column

I have a file which looks like this: 1 1 2 5.24 3 12.46 4 21.56 and so on. I need to change it to: 1 1 3 5.24 5 12.46 7 21.56 on a quick way. So the first column has to have odd values 2i+1 for i ...
0
votes
1answer
27 views

How to add the value of this column? (us+ sy+id+wa)

I want to find for the CPU Utilization. So, I am trying to add the us, sy, id, wa column.Is it possible to do the addition for those 4 column. Any suggestion? procs -----------memory---------- ---...
3
votes
3answers
70 views

search column 2 in csv file for value, if value, then insert “invalid” and shift cells right

I have csv file that is auto generated by a script but for some of the records (line items) received I need to search column 2 and if the values contains "*.app" I need to print "INVALID" into column ...
4
votes
1answer
80 views

How to display columns in tab separated files nicely?

I have some Tab separated files that consist of a header that are quite unreadable because of the different length of table entries. Essentially, it looks somewhat like c1 c2 c3 c4 A 0 ...
0
votes
2answers
112 views

Git-bash UNIX: Switch columns/fields using cut?

So I have a file with 2 columns as follows: 10 1 11 2 12 3 13 4 14 5 I would like to switch the columns using the cut command. I've used paste <(cut -f2 file.dat) <(cut -f1 ...
0
votes
1answer
38 views

merging files with the same 1 column

I have multiple files named p1.bbmap.mapping.csv, p2.bbmap.mapping.csv, p3.bbmap.mapping.csv ... p3.bbmap.mapping.csv Each file has two columns. p1_60_length_504_cov_1.580902 12 ...
1
vote
2answers
60 views

How to change values of one column using other column's values from a different file

I don't know what command should I use in unix. Let say I have a file like this: A 23 B 52 C 36 F 25 and second file with 3 columns: A aligator 2 B panda 3 C bear 4 D pig 1 E yeti 0 ...
1
vote
2answers
485 views

Aligning output in Linux paste command

How can I make the second file in a paste start in the same spot regardless of the length of the line in the first file? For example: file1: small incredibly humungous file 2: A B I want paste ...
0
votes
1answer
58 views

How to print multiple columns without truncating?

I know that pr -m -t file1 file2 will give me 2 columns like so: file1: a abc abcdefg abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz file2: 1 123 12345678 12345678901234567890 - $ pr -m -t ...
1
vote
4answers
601 views

Is it possible to put double quotes in just a few columns using sed?

I'm doing my course completion work where I need to manipulate some columns of a .csv file that has six hundred thousand lines. I have already searched in several forums on sed and awk and I did not ...
0
votes
1answer
16 views

How do I add the filename after the content of the first column?

This is my original file called NAME.xxx columnname1 columnname2 columnname3 XX_XX_XX_XX number number YY_YY_YY_YY number number ZZ_ZZ_ZZ_ZZ number number This is how I would like ...
1
vote
0answers
17 views

column Removes Whitespaces at Process Substitutions

I try to display two statistics of my nginx-server side-by-side. My first approach for this is column and process substitution. column <( echo "sorted by busiest access times:" ...
1
vote
2answers
71 views

Deleting end of line if column starts with character

I have a large file, where the second column has some lines that need to be truncated. Currently it is: 10 10:135524264:C:G 0 135524264 C G 10 rs55726203:135524334:A:G 0 135524334 A G If the second ...
3
votes
1answer
323 views

awk - dynamically format tab-separated columns

I have a file with dynamic length columns (four) separated with tabs (a column can have have spaces) COL1 COL2 COL2 COL2 COL3 COL3 COL4 COL1 COL2 COL2 COL3 COL4 COL4 COL1 COL1 ...
0
votes
1answer
57 views

Merging columns from 200+ big files into one table

I have 200+ large files that all have exactly 1 column and 76M rows. I want to start a newfile.txt and slap the columns next to each other (match Line 1 of File 1 with Line 1 of File 2... and continue ...
1
vote
1answer
88 views

How to change line width in “info” command

Is it possible to make lines in the info command wider? An example : When running info awk I get the following output, although the terminal size is much wider. 2 Running 'awk' and 'gawk' **********...
0
votes
1answer
214 views

Sum First Column on basis of Second Column

I have written a Bash script which stores the number of records(line count) in a file and File name which is present in the directory in a output.txt file. The output.txt file is as below. No....
2
votes
3answers
79 views

Merge columns and add

I have a file with the following content (there are additional spaces to pad the first column) 1 account1 192.168.0.1 1 account1 192.168.0.2 19 account2 192.168.0.1 100 account3 192.168....
5
votes
4answers
323 views

How to split field 1 into distinct rows but keep field 2 copied for each new row created

Input: Note: 2 columns separated by a tab, regular spaces separating words in column 2. 1 the mouse is dead 2 hit the wall 3 winter lasts forever Wanted output: 1 the 1 mouse 1 is 1 ...
-2
votes
3answers
24 views

Compare Columns of genes in file and output the gene and number of column it is present in linux

I have 3 coumns of genes in a file like this col1 col2 col3 CXCL9 CXCL9 CXCL9 MAP2K6 MAP2K6 MAP2K6 CXCL10 CXCL10 CXCL11 I want to match the 3 columns and see which gene is present in ...
1
vote
2answers
93 views

How to insert a column between two other columns of output?

Please note that I'm aware of this and this but they didn't help me. I want to combine the outputs of two commands. ls -1sh And wc -l so I can do something like: <combined command> o.img 1....
0
votes
1answer
48 views

How to merge two files containing lists to one file with two columns?

I have the file mail.txt which contains the list of some emails and the file names.txt that includes the names of those people accordingly. Now I want to combine these files to one files with the ...
2
votes
2answers
90 views

join returns nothing

I have two files with columns separated by tab and I want to merge them file a01 a= b= c= d= e= f= g= h= i= j= k= l= m= n= 0= file b01 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 ...
1
vote
3answers
76 views

sort File B based on column 3 of File A without changing contents of File A

I have the following file: cat fileA.txt seattle 1991 west atlanta 1993 west turlock 1998 west marysville 2004 south newyork 2007 north canada 2004 west And the second file ...
1
vote
3answers
266 views

Print only certain columns while maintaining white space

I have some code that prints select columns from the output of lsblk. However, the spacing in the result makes it hard to read. Is there anyway to do this while maintaining the white space? echo "`...
2
votes
2answers
97 views

How to cut the last 5 strings in one particular column for all rows

I have a file with multiple columns and rows, and I need to cut the last 5 strings of my third column and print it in an extra column. For example: 1 info1 AAAAAAAAAAA 2 info23 TTTTTTTTTT 3 ingo45 ...
3
votes
1answer
104 views

merging files in a one dataframe

I have almost 160 txt files, each file has 7 columns and now i want to put that in one file. Each files 1st and 6th column data (Geneid, Length) is same so i just want that to be the 1st and 2nd ...
22
votes
3answers
13k views

Bash shell script output alignment

My script: date echo -e "${YELLOW}Network check${NC}\n\n" while read hostname do ping -c 1 "$hostname" > /dev/null 2>&1 && echo -e "Network $hostname : ${GREEN}Online${NC}" || ...
-1
votes
1answer
90 views

Bash script that can output specific parts of a tacacs file into columns

I'm trying to output parts of a tacacs file into a monthly report. Have tried doing it in python but my result still has errors, so I thought I'd try and see if there's a elegant solution within a ...
3
votes
1answer
116 views

Merge 2 huge files matching multiple columns and preserving the order (print matching and non-matching values) - scale up from awk

I'm having trouble with merging data from 2 files. It is genetic data with chromosome, position, reference and alternate alleles and I need to merge the files by matching all 4 of those columns - with ...
1
vote
2answers
166 views

How to print a specific column to a file if condition seen in multiple files?

I have a bunch of files (totally 2181 files; anacovis2_1_summary_betai_reg.out ~ anacovis2_2181_summary_betai_reg.out) like below: anacovis2_2_summary_betai_reg.out anacovis2_3_summary_betai_reg.out ...
4
votes
3answers
2k views

How to optimize script with NF and a for loop

I have several files, each one with different number of columns. I want to convert them to insert them in a database For example the file test01: 0001 000000000000001 john smith 45 500 0002 ...
1
vote
1answer
2k views

printing row-based data in a table format on Linux

I have the below data in a file: col1 col2 col3 subcol1 subcol2 subcol3 subcol4 subcol5 subcol6 col4 subcol7 subcol8 subcol9 subcol10 subcol11 subcol2 The ...
3
votes
1answer
301 views

How can I calculate the average of multiple columns with the same value for the first two columns?

I have a file of about 13 million lines like: Lat Long air_temp sst wind_speed wave_height wave_period 65.3 7.3 4.3 8.8 7.7 4 8 61.6 1.3 -9.99 8.8 9.8 4 7 61.2 1.1 -9.99 8.8 7....
1
vote
3answers
1k views

How to replace empty cells of a specific column

I have a file with many columns and some empty cells in different columns. I would like to replace the empty cells for NA only in the third column. My file: 1 id1 info 2 otherinfo 3 id2 4 ...
1
vote
1answer
116 views

Join two tables based on non-sharing values in chosen column

I have been using "Perl for biologists with little computer coding knowledge" from site called Scriptome (Harvard). It gives great Perl one-liners to achieve desired functions which runs on Unix ...
0
votes
1answer
80 views

Arrangement of column next to last Nth instance of delimiter

I have the following data in my file alice bob cathy david elon unix linux bsd I want output with only the last Nth instance of delimiter (ie. a space) being arranged Like for last instance of ...