LinuxQuestions.org
Help answer threads with 0 replies.
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 05-11-2004, 11:38 PM   #1
supreme_command
LQ Newbie
 
Registered: Feb 2004
Distribution: Mandrake
Posts: 7

Rep: Reputation: 0
Extracting Lines from files


Hey
I know this is probably a pretty simple questions

But how can i extract one line at a time from a file and then be able to do operations on the line - for a script

like

for line in $(....
do
..
 
Old 05-12-2004, 05:21 AM   #2
Bebo
Member
 
Registered: Jul 2003
Location: Göteborg
Distribution: Arch Linux (current)
Posts: 553

Rep: Reputation: 30
Hello,

Do something like
Code:
FILE="~/a_file"

cat $FILE | while read LINE ; do
   bla bla
done
This way you get whole lines from the file in LINE. There is an alternative, but that way LINE would contain every word one at a time, not whole lines:
Code:
FILE="~/a_file"

for line in `cat $FILE` ; do
   bla bla
done
HTH
 
  


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
Assistance with extracting a series of lines from a log file katsal Linux - General 1 06-21-2005 07:55 PM
Self extracting .bin files manticor Linux - Software 8 01-17-2005 12:12 PM
extracting .gz files MACSRULE Linux - Newbie 2 04-13-2004 07:16 PM
Extracting files BriceM Linux - General 3 08-15-2003 04:00 PM
extracting files jester_69 Linux - General 5 05-20-2002 12:21 AM


All times are GMT -5. The time now is 08:48 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