Wednesday, May 28, 2014

Split pipe separated column in Linux

Suppose you have a file that have pipe ("|") separated values.

122344|093462|45836
472391|093742|23444

If you want to split column 2 values, you can use the following command to get second column values easily.

cat log.txt | awk -F"|" '{print $2}'>second_column_log.txt

This will create a file called "second_column_log.txt" that contains column two values.

093462
093742

No comments:

Post a Comment