LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-26-2013, 12:29 PM   #1
dumblinuxuser
LQ Newbie
 
Registered: Nov 2013
Posts: 7

Rep: Reputation: Disabled
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,
 
Old 11-26-2013, 12:34 PM   #2
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Code:
head -1 file | tr "|" "\n"
 
2 members found this post helpful.
Old 11-26-2013, 12:41 PM   #3
dumblinuxuser
LQ Newbie
 
Registered: Nov 2013
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thanks a bunch colucix.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to read CSV data and compare the column values and then write them in new file VijayaRaghavanLakshman Linux - Newbie 9 01-26-2012 10:02 PM
[SOLVED] Read a number x from a file and write a character in the xth column of other file homexylo Programming 7 08-05-2011 06:28 AM
3D array in MAT file ->DAT file to read in FORTRAN BrandonPossible Programming 2 07-03-2009 02:14 AM
Read text file column by column RVF16 Programming 11 05-31-2009 08:16 AM
I can not read arabic file names. AGazzaz Linux - General 5 09-27-2007 03:18 PM


All times are GMT -5. The time now is 01:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration