Skip to main content

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
0 votes
4 answers
94 views

command-line tool to sum the values in a column of a CSV file

I am looking for a command-line tool to calculate the sum of the values in a specified column of a CSV file. (Update: The CSV file might have quoted fields, so a simple solution just to break on a ...
halloleo's user avatar
  • 589
1 vote
5 answers
94 views

how to columnate list of strings in two lines, aligned to the length of the first column

I have a list of strings: python2-distutils-extra|==>|python2-distutils-extra|2.39-5|Enhancements to the Python build system python2-fuse|==>|python2-fuse|1.0.5-1|This is a Python 2 interface to ...
ludvick's user avatar
  • 25
2 votes
1 answer
138 views

What is the purpose of the column with the '0' after the numeric timestamp in .zsh_history?

What is the purpose of the column with 0 after the numeric timestamp in .zsh_history? : 1568128379:0;cp -a ~/.zshrc.pre-oh-my-zsh ~/.zshrc : 1568128381:0;exit Is it part of the timestamp or does it ...
vfclists's user avatar
  • 7,619
0 votes
1 answer
129 views

handling columns with whitespaces

A hashing command gives the hash and the path separated by a whitespace: k3j48fajsdjf4w8fj path to file/file 1.txt I want to create a table where one column is the hash and the other column is the ...
Fabio's user avatar
  • 153
4 votes
3 answers
1k views

Visually aligning columns of a CSV file

Using sed or awk, is it possible to visually align columns in a CSV file? For example: e.g. from: a,b,c,some stuff,"some, other, stuff",d,2023-03-10 18:37:00 y,x,z,t,cool,thing,2022-04-12 21:...
s.k's user avatar
  • 471
-1 votes
1 answer
61 views

How can I format the output of a shell command into columns, but limit the number of columns created?

Say I run systemctl | grep running | column -t I get an output that looks like this: init.scope loaded active running System and Service Manager session-...
DrKumar's user avatar
  • 119
-1 votes
4 answers
84 views

column(1) drops blank leading cells; is it fixable?

Consider this usage of column(1): column -s, -t <<CSV a,b,c ,ee,ff CSV The above snippet emits: a b c ee ff But I was expecting to see something like this: a b c ee ff column ...
shadowtalker's user avatar
  • 1,358
2 votes
1 answer
52 views

rs(1) prints all output in a single line; how to duplicate the input array shape?

Consider this usage of rs(1): rs -n -z -c, <<CSV a,b,c dd,ee,ff CSV The above snippet emits: a b c dd ee ff But I was expecting to see something like this: a b c dd ee ff The ...
shadowtalker's user avatar
  • 1,358
0 votes
4 answers
174 views

output a column group by another columns in shell

Thanks in advance! I have a file with 3 columns like this: serv1 red group1 serv1 black group1 serv1 orange group1 serv1 red group2 serv1 orange group2 serv1 red group3 ...
iam's user avatar
  • 3
0 votes
0 answers
140 views

Removing duplicate values based on two columns

I have a file that would like to filter duplicate values based column 1 and 6 ID,sample,NAME,reference,app_name,appession_id,workflow,execution_status,status,date_created 1,ABC,XYZ,DOP,2022-08-18 13:...
nbn's user avatar
  • 113
1 vote
2 answers
277 views

Converting column of values from positive to negative

I have an XYZ file, most of the Z values are positive but in fact should be negative. I am wanting to convert all positive values in column three to negative (keeping values already negative the same)....
Lou's user avatar
  • 13
2 votes
2 answers
855 views

Applying function to first column and inserting it as second

So I have been searching like crazy, but I still have not found a satisfactory solution. I have some output which looks like the following kdeconnec 1625 1000 11u IPv6 414426 0t0 UDP *:...
N3buchadnezzar's user avatar
2 votes
4 answers
593 views

Combine columns into one column (stack)

I have multi-column data that I wish to reformat such that each column follow "on top" of each other in one single column. Example input: 1 2 3 4 1 2 3 4 Desired output: (fixed old ...
Stalpotaten's user avatar
0 votes
2 answers
96 views

how to add a number as well as format change to column value and print it in 3rd column

I have these two columns with header: CHR BP 1 78901 I need to add a character to the first column numbers (chr). I also need to make a third column in which one score being added to the second ...
motor 30's user avatar
2 votes
1 answer
787 views

format to columns for real-time data (pipe)

Is there a way to do column-like filtering on data comming through a pipe? I am looking for a way how to do a similar thing that column -t does, but without waiting for the input to end so it would ...
user185953's user avatar
0 votes
2 answers
141 views

Combining files column-wise by first column as key (using grep or awk, etc.)

Here are my two files 1.txt 1 2 3 4 5 2.txt 2 a 5 3 than i get the file by awk -F '\t' 'NR==FNR{F1[$0];next}$1 in F1{print}' 1.txt 2.txt 2 a 5 3 but i want to get file like ...
loki's user avatar
  • 43
0 votes
2 answers
176 views

How to extract columns from one file and move to another file without printing the columns?

I have a 2GB csv file called data.csv. I want to extract 5 columns from data.csv and move to a new file (preferably a new csv file). How can I do that? Is there an awk command which allows me to do ...
kanha's user avatar
  • 3
3 votes
1 answer
291 views

align data by word into column

How can I align data into pretty columns relative to given word? For example, I have output of the route -n command: default via 172.20.99.254 dev eth0 87.33.17.71 dev tun0 scope link 89.223.15.12 ...
Martin Vegter's user avatar
0 votes
1 answer
245 views

AWK to replace 2nd column by minus with 1st data from specific line

I would like to get the 1st data on 1st column (i.e:1.20E-05) and replace the whole second column by minus with this 1st data. Then, i would like to delete the last data line and print to a new file. ...
bihqui tiang's user avatar
1 vote
6 answers
351 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!...
Rama Krishna Majety's user avatar
0 votes
2 answers
4k 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 ...
Yash54's user avatar
  • 19
1 vote
1 answer
104 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 ...
Fajela Tajkiya's user avatar
1 vote
1 answer
192 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 ...
LEENAKS's user avatar
  • 11
-1 votes
2 answers
369 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)...
lm19246's user avatar
1 vote
2 answers
3k 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 ...
Rea Kalampaliki's user avatar
-1 votes
3 answers
144 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\...
Todd Telle's user avatar
2 votes
2 answers
2k 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 ...
Porcupine's user avatar
  • 2,056
5 votes
1 answer
864 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 $ ...
Luca Etienne Schulz's 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 ...
mcv110's user avatar
  • 13
-2 votes
1 answer
245 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,...
priyanka's user avatar
-4 votes
3 answers
1k 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 ...
priyanka's user avatar
0 votes
3 answers
55 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 ...
Biophysicist's user avatar
0 votes
2 answers
127 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 ...
ShapeOfMatter's user avatar
1 vote
4 answers
5k 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 ...
David Montana's user avatar
0 votes
1 answer
501 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 ...
mariner108's user avatar
1 vote
3 answers
282 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 ...
Þórdís Þórarinsdóttir's user avatar
3 votes
1 answer
115 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 ...
fdmillion's user avatar
  • 2,918
1 vote
2 answers
520 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 -...
Pierre-Jean's user avatar
  • 2,259
0 votes
0 answers
719 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 ...
Dave S.'s user avatar
-1 votes
3 answers
85 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 ...
MJD's user avatar
  • 1
1 vote
3 answers
2k 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=...
Bison-Ex1's user avatar
0 votes
2 answers
249 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....
kllrdr's user avatar
  • 71
0 votes
1 answer
650 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....
kllrdr's user avatar
  • 71
0 votes
3 answers
67 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 ...
Ashar's user avatar
  • 511
0 votes
1 answer
90 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 ...
Magi's user avatar
  • 1
-1 votes
3 answers
363 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 ...
Yanik's user avatar
  • 1
6 votes
4 answers
3k 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/...
Wolf's user avatar
  • 1,641
1 vote
1 answer
2k 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 ...
Ray Andrews's user avatar
  • 2,527
1 vote
2 answers
971 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. ...
sai's user avatar
  • 77
1 vote
2 answers
210 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 ...
deamentiaemundi's user avatar

1
2 3 4 5
7