Skip to content
Advertisement

Linux split a file in two columns

I have the following file that contains 2 columns :

JavaScript

How is possible to split the file in 2 other files, each column in a file like this:

File1

JavaScript

File2

JavaScript

Advertisement

Answer

Perl 1-liner using (abusing) the fact that print goes to STDOUT, i.e. file descriptor 1, and warn goes to STDERR, i.e. file descriptor 2:

JavaScript

You could, of course, just use cut -b with the appropriate columns, but then you would need to read the file twice.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement