How to sort files in command line and join them?

linux
shell
unix
bash

#1

How do you sort files in command line and join them together to gather info required for analysis?


#2

Try sort command. It depends upon what are you trying to sort. The syntax is:

sort file
sort [option] file

File can be joined together again depend upon your needs. Simple append can be done with cat command:

cat file1 file2 file3 > out

Use paste command to merge lines of files. Maybe you can provide some more info including sample data.


#3

sample data AND expected corresponding result


#4

cat * | sort -o MYDATA

if you want just to sort per file then put them all in one file;
( ls * |xargs -i sort {} )>MYDATA


#5

what’s your email? I’m hoping to send you some files and show you what I’m having trouble with unless your busy?


#6

when you ask questions to a forum everything has to be visible to everyone.


#7

You can upload images and other files or just paste sample data.


#8

but please, don’t post screenshot of the terminal, do a copy/paste.