LinuxQuestions.org
Review your favorite Linux distribution.
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 10-21-2005, 09:29 PM   #1
BigChuckP
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
homey
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
shengchieh
Member
 
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.

Sheng-Chieh
 
Old 10-22-2005, 12:36 AM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 23,066
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.


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

Original Poster
Rep: Reputation: 0
Quote:
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
muddywaters
Member
 
Registered: May 2005
Location: Winnipeg, Canada
Distribution: mostly mepis
Posts: 427

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


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
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


All times are GMT -5. The time now is 07:32 PM.

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