LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Extracting Lines from files (https://www.linuxquestions.org/questions/linux-newbie-8/extracting-lines-from-files-180536/)

supreme_command 05-11-2004 10:38 PM

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

Bebo 05-12-2004 04:21 AM

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


All times are GMT -5. The time now is 11:52 PM.