Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 10-21-2005, 09:29 PM   #1
LQ Newbie
Registered: Oct 2005
Posts: 9

Rep: Reputation: 0
How to read a file

Ok so I have a file I need to read. The file has 7 columns in it and I need to cut out some of the columns and then redisplay the file.
Thank you for any replies.
Old 10-21-2005, 09:39 PM   #2
Senior Member
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 59
You could start with cat and pipe to cut.
For example:
cat file.txt | cut -d" " -f1
Old 10-22-2005, 12:01 AM   #3
Registered: Jul 2004
Location: Palo Alto, CA
Distribution: #! Korora
Posts: 472

Rep: Reputation: 30
If the file is "nice", you could open it up in a database
program (oo has one), trim off the column(s), edit, etc.
The only drawback is when you save as ... -> text file,
the spacings in the columns may change.

Old 10-22-2005, 12:36 AM   #4
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910Reputation: 910
First off, welcome to LQ,

And then: the question smacks of home-work; if it is,
please re-read our rules which you agreed to when you
signed up earlier, and don't post home-work questions
again ... If I'm getting the wrong idea please explain what
the actual task is you need to achieve.

Old 10-22-2005, 10:00 PM   #5
LQ Newbie
Registered: Oct 2005
Posts: 9

Original Poster
Rep: Reputation: 0
Originally posted by homey
You could start with cat and pipe to cut.
For example:
cat file.txt | cut -d" " -f1
Awesome thanks. I am used to java and VB where you have to put files in arrays and use file readers.
Old 10-22-2005, 11:22 PM   #6
Registered: May 2005
Location: Winnipeg, Canada
Distribution: mostly mepis
Posts: 427

Rep: Reputation: 30
Another option would be awk. Nice introduction at this site
If it's homework I apologize for breaking the rules, but I was using this myself today and it was definitely play, not work.


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
Read parameters from config file (file parser?) alaios Programming 8 07-09-2012 12:29 PM
How to read .chm file in fedora, can't mount ntfs file system ishti_du Linux - Newbie 12 03-06-2007 04:27 AM
How to read variable from one file & update its value in another file minil Programming 1 03-22-2005 01:12 AM
how do I make a read-only file NOT read-only? robster Linux - General 1 02-17-2004 10:11 PM
Change from Read only to Read Write File System? justiceisblind Linux - Newbie 3 03-03-2002 08:23 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:00 AM.

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