LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   read only column names from DAT file (https://www.linuxquestions.org/questions/linux-newbie-8/read-only-column-names-from-dat-file-4175485941/)

dumblinuxuser 11-26-2013 11:29 AM

read only column names from DAT file
 
Hello Guys,

I am struck trying to accomplish a specific tasks and need some help to proceed forward.

I have a DAT file with more than 100,000 lines, the first line is the header.

looks like: col1|col2|col3|col4|col5|col6|col7|col8|col9|col10

I need to read only these columns from this file for which I am doing
head -1 <file-name>
output: col1|col2|col3|col4|col5|col6|col7|col8|col9|col10

but if i want an output like:
col1
col2
col3
col4
col5
col6
col7
col8
col9
col10

what should my command look like.

Help is much appreciated.

Thanks,

colucix 11-26-2013 11:34 AM

Code:

head -1 file | tr "|" "\n"

dumblinuxuser 11-26-2013 11:41 AM

Thanks a bunch colucix.


All times are GMT -5. The time now is 03:00 PM.