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.

Filter by
Sorted by
Tagged with
1 vote
6 answers
105 views

AWK one liner to merge three fields in a single file

I have a file with records (lines) having two types of field delimiters | and ! as given below: Name|Age|Physics|Chemistry|Maths|English|Batch!Year!AdmisnNo!Grade!Score Student1|81|65|70|80|88|EWS!...
user avatar
0 votes
2 answers
63 views

Copy specific Column from multiple csv file and write it to new csv file. Shell Scripting

I have multiple CSV files from these I want to extract 3rd column and write it new file, in the same manner, the file is sequenced in a folder. Append should be in such a manner that all the columns ...
user avatar
  • 19
1 vote
1 answer
53 views

How does the default -s option of the "column" command work? How can I mimic the default -s option by manually passing it some value?

The manpage of the column command describes the -s option like this: -s, --separator separators Specify the possible input item delimiters (default is whitespace). It says by default, -s is ...
user avatar
1 vote
1 answer
13 views

Reorder iostat output with time next to the device column

I am trying to reformat the iostat data. Current output: TimeA Column1 Column2 Column3 disk1 10GB small disk2 20GB medium disk3 30GB large TimeB Column1 Column2 Column3 disk1 ...
user avatar
  • 11
-1 votes
2 answers
53 views

Extremely large text file manipulation (adding a column; changing contents of column)

I have a set of very large (80GB) files (genomic variants dosage) which are ".txt.gz" at the moment and have the following layout (columns/variables): Chr RSID POS REF ALT Ind1 Ind2...Ind(n)...
user avatar
0 votes
2 answers
348 views

Write two variables in a two-column file (tab-separated)

Hello GNU/Linux newbie here. I want to write two variables in a two-columns tab-separated file. In my code, the variables are $sample_name and $file. I use the commands: touch to create the file and ...
user avatar
-1 votes
3 answers
53 views

Trim pathname in CSV file

I am struggling over a filter where I am trying to trim data in a specific column of a CSV after the 3rd or nth occurrence of the character \. My data looks something like this: data,data,c:\path1\...
user avatar
0 votes
0 answers
76 views

merge 2 files in linux based on 4 columns on the command line

I have two data sets. Dataset 1 is a txt.gz file with 4 columns with information and another column filled with na. Dataset 2 is a vcf format .gz file and I need to use this second data set to 'merge' ...
user avatar
  • 1
0 votes
2 answers
108 views

`column` from `util-linux` and not from `bsdmainutils`

column is available in packages util-linux and bsdmainutils. Both these packages are installed in Linux Mint 20.2 $ type column column is /usr/bin/column column is /bin/column Both these column are ...
user avatar
  • 1,362
5 votes
1 answer
117 views

How to format a single line using column?

I have a basic phone book in a file phonebook.dat. $ cat phonebook.dat Onkh,Gregor:0123456789 Steinert,Franz:02473894091 Rubrecht,Magdalena:01474653371 I can then format this file using column $ ...
user avatar
0 votes
0 answers
32 views

awk output not in columns when moved to log [duplicate]

I have an awk command piped to the output of another command | awk {'print $2,$3'}. When I run this command the output displays the data in columns, of the columns as I would expect column2 column3 a ...
user avatar
  • 13
-2 votes
1 answer
73 views

modify the columns

This is my dataset: chr1_KI270706v1_random,153401,rs867658023,chr1_KI270706v1_random_153401 chr1_KI270706v1_random,154751,rs1030747857,chr1_KI270706v1_random_154751 chr1_KI270706v1_random,156703,...
user avatar
-4 votes
3 answers
109 views

merge two columns

I am trying to merge two columns into one column. My dataset look like this: RSID1 RSID2 rs7475652 rs7475652 rs7475652 rs7918643 rs7475652 rs3125034 rs7475652 rs3750730 rs7475652 rs883728 rs7475652 ...
user avatar
0 votes
3 answers
43 views

Exclude line from output file if charaters in columns 9-14 aren't found in another file

I have two column delimited files and I need to create two new files of only the records where the transaction identifiers were found in both files. The identifier is in a field spanning from columns ...
user avatar
0 votes
2 answers
75 views

Use linux version of a command instead of the BSD version

I have a utility bash script from an old laptop that I'm trying to use on my current laptop. It fails because it's passing unknown options to the column command. Running man column, I see that this ...
user avatar
0 votes
4 answers
764 views

add column, populate entire column with name of file (without the ".csv") -for multiple files in BaSH

Caveat: Absolute beginner. I need to add a column to a .csv file where the column header can be "Name", but the entire column should be exactly the same -- the name of the file itself, the ...
user avatar
0 votes
1 answer
118 views

Displaying number of columns and items in columns using a for loop

I'm writing a BASH script that asks a user for the number of columns and the number of items to put in the columns. The script will then put the numbers in the columns using for loops. # Number of ...
user avatar
1 vote
2 answers
66 views

I want to join two files and KEEP all the white space

I am trying to join two data files. The first one has 100.000 records where each line represents one person. The second file has 400.000 records where a person in the first file can appear multiple ...
user avatar
3 votes
1 answer
80 views

Is there a trick to re-align tabular data in the terminal after filtering with grep?

Good example of what I'm getting at: try doing ss -axl to show listening UNIX domain sockets. For example, this might give: Netid State Recv-Q Send-Q ...
user avatar
  • 2,408
1 vote
2 answers
137 views

Zero/Nul separator breaks column command

Problem I want to parse some data structured as lines (\n separated) with fields separated by the NUL character \0. Many linux commands handle this separator with options such as --zero for find, or -...
user avatar
  • 2,067
0 votes
0 answers
197 views

display grid of data in bash

would like to get an opinion on how best to do this in bash, thank you for x number of servers, each has it's own list of replication agreements and their status.. it's easy to run a few commands and ...
user avatar
-2 votes
3 answers
81 views

Take the lines between two specific values from different columns in a txt file [closed]

I have a txt file (as show below) with many columns and I need to get the lines contained between the position of the second column to the position of the third column. 1 10385389 ...
user avatar
  • 1
1 vote
3 answers
379 views

How to extract certain columns with AWK from one CSV file to another?

I have a very big CSV log file that contains fields like this: aaa=somedata1,bbb=somedata2,ccc=somedata3,eee=somedata5,hhh=somedata8 aaa=somedata1,ddd=somedata4,fff=somedata6,hhh=somedata8 aaa=...
user avatar
0 votes
2 answers
77 views

How to select the top 2% of the values from a column, then write 1 if it is true and 0 when it is false?

I have the following table: CHR BP SNP CM AN1 1 15558213 rs2845371 0 -1.10837716961610 1 15558230 rs16981507 0 -1.13721847993853 1 15558586 rs5993924 0 -1.34239265871644 1 15563103 rs3016111 0 -1....
user avatar
  • 71
0 votes
1 answer
82 views

How to delete characters after a "." (dot) in the first column?

I want to delete characters after "." in the first column of my file, which looks like this: location LR alpha 14884399.000000 0.471193 3.029710e+01 14904434.024291 0.440564 1....
user avatar
  • 71
0 votes
3 answers
33 views

Unable to get the nth column data due to changing output of uptime command

Below is the output of uptime from Solaris where I am extracting the third last column: uptime 8:30pm up 23 day(s), 17:46, 5 users, load average: **2.79**, 1.79, 1.53 I always need to get the ...
user avatar
  • 297
0 votes
1 answer
41 views

Putting single quote in the begining of column

I have a .txt file with publications for which columns are separated by a single space. However, titles also have spaces an in order to separate the columns correctly I need to have all titles in ...
user avatar
  • 1
-1 votes
3 answers
183 views

Bash Split Output Groups to Columns

I have similar output like below goes so long. I want to create columns with this output but with like groups/blocks. And process output after a pipe. id: c2b751c227111edfgdghfhfg19079a466e1916f6df4 ...
user avatar
  • 1
5 votes
4 answers
394 views

How to print multi-line variables in side-by-side columns in sh?

This question is based on a similar question on Ask Ubuntu, but instead of bash, I would like to have similar output in sh. No issue in bash; it works as expected. wolf@linux:~$ echo $SHELL /usr/bin/...
user avatar
  • 1,221
1 vote
1 answer
469 views

'Invalid or incomplete multbyte or wide character' with 'column'

I'm on a Linux system and I'm trying to use 'column' on a file that I've spiked with an extended character to use as the separator. Reason being that any normal printing character is liable to show ...
user avatar
  • 1,789
0 votes
2 answers
396 views

How to join columns from two files using awk/sed command?

I have two files File-1 and File-2 with data in columns. I want to create another file and copy the data of the first column of File-2 corresponding to the data to file-1 in row wise as given below. ...
user avatar
  • 67
1 vote
2 answers
104 views

Right align last word in a line

…which does not exist in every line Example with | marking the maximum length of the line, say 79 characters excluding line-ending(s) and SPECIAL_WORD be the last word mentioned in the title: Some ...
user avatar
0 votes
1 answer
101 views

How to set proper columns in bash terminal?

I am trying to define proper columns to my code output. The problem is that if one of column's elements is empty/not within character limit, the subsequent column elements get displaced. VULDB-ID ...
user avatar
0 votes
1 answer
39 views

post-processing of multi-column log file

I am working on post-processing of multi-column log filles, in the following format: /Users/gleb/Desktop/scripts/analys_clusters/sub_folders_to_analyse/7000_cne_lig420.AllBoxes/7000_07_lig_cne_420,6, -...
user avatar
  • 187
1 vote
3 answers
177 views

Emulate a number of columns for a program in the terminal

I have a program that I'd like to run, deluding it to believe that my terminal has less columns than it does, because that enables its native truncation, which I need. I tried resize from xterm as ...
user avatar
  • 395
1 vote
3 answers
37 views

Find columns based on contents of respective first rows

So I have a TSV file that looks something like this: Hello world how are you 1 2 3 4 5 6 7 8 9 0 (I've separated everything within each row with a single whitespace in the hand-written toy example ...
user avatar
  • 111
1 vote
2 answers
769 views

Uniq based on last field, keeping last line, and append number of duplicates

I need some help to implement awk command in a bash script for implementing below logic. Tried sort/uniq combination, but no luck. I have a long list with time stamp and some number in front of it ...
user avatar
  • 43
0 votes
2 answers
88 views

Remove duplicated first fields of a CSV file

I try to remove repetitions of the same value of the first column from a CSV file without changing the other cell contents and alignment (in other columns). My txt: ACCIDENT EP 4 STEM PERCUS,, ...
user avatar
0 votes
1 answer
57 views

Portable solution instead of using Debian specific `column -n`

I know that on Debian Linux distros, there is an extension -n flag to prevent column command from merging multiple adjacent delimiters into a single delimiter when using the -t option. But, I was ...
user avatar
0 votes
1 answer
131 views

Keeping columns of csv file based on condition of columns of header line

I wish to keep only certain columns of a CSV file, based on the structure of the header line. Description of data: In the header line (fields of country), several fields are empty.  The number of ...
user avatar
  • 3
4 votes
3 answers
166 views

Introducing a line break into a file having different columns on the basis of text in the value column

I would like to introduce a line break into a file having different columns on the basis of the value in the first column. For example: Input file: 1aa6 HETATM 4MO A 803 1aa6 HETATM SF4 A 800 1ao0 ...
user avatar
-2 votes
4 answers
68 views

How do I count all letters in a column, alphabetically

How can I count all letters in a column from "a" to "z" in a .tsv file with an output telling me how often each letter appears? For example lets say this is a column abc abd aabf ...
user avatar
0 votes
2 answers
158 views

sum columns based on header

I have a tab-separated file1 like this (subset shown, real matrix 60x60000): rowname header1 header2 header3 header4 header5 header6 header7 header8 rowname1 1 1 10 2 3 ...
user avatar
  • 23
0 votes
2 answers
38 views

split output into 2 columns based on number of rows

I have the following output: Column1 1.2.3.1 1.2.3.2 1.2.3.3 1.2.3.4 1.2.3.5 1.2.3.6 Column2 1.2.3.7 1.2.3.8 1.2.3.9 I would like to split into 2 columns once it reaches Column2. For example: ...
user avatar
1 vote
1 answer
403 views

How to solve the alignment problem of the columns in a text file after copy and paste?

I copied column 7,8 and 9 from file 1 into columns 7,8 and 9 in file 2 producing a new file 3. the produced file (file 3) is not aligned as the original files, How can I edit it to preserve the ...
user avatar
0 votes
1 answer
37 views

How to get multiple variables within a single neat column?

I want to display a list like this: | A | B | Item #1 | 291+4 | 56145+3 | Item #2 | 7391+92 | 105+6067 | but it looks like this: | A | B | ...
user avatar
-1 votes
3 answers
488 views

AWK How to take value from header and print it in columns?

I have to get some values from header in txt files and duplicate them as column the number of rows change from file to file , here is an example. Input file: PROJECT : PRK33 X_COR : 258524 Y_COR : ...
user avatar
0 votes
1 answer
77 views

Duplicate columns of a bed file to produce another bed file

I have a bed file genome_cov.bed specifying the coverage of a genome at every position on the genome. The columns are; scaffold, position, coverage. scaffold_1 1 0 scaffold_1 2 ...
user avatar
1 vote
1 answer
169 views

Sum column values across multiple dataframes

Suppose I have 3 dataframes (independent .txt files): Acamar Begalb Caspri Acamar 0.1 0.0 6.3 Begalb 0.33 8.3 0.0 Caspri 1.4 0.617 2.4 ...
user avatar
2 votes
4 answers
415 views

How can I extract rows from a table and put into a separate file?

I have a table that has 5 columns and multiple rows The last column has the sum of all values for each row like that: A B C D E gene1 1 3 5 9 gene2 0 0 4 4 gene3 1 ...
user avatar
  • 27

1
2 3 4 5
7