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 01-15-2009, 09:10 AM   #1
madi3d8
LQ Newbie
 
Registered: Jan 2009
Posts: 1

Rep: Reputation: 0
Post I would like need a suggestion on bash shell : Read a file line by line and do stuff


At first, give my best wish for all MOD and admins here. I"m learning bash shell program just for a month, not too much, not too little, but i must admire that i'm very bad at math and algorithm.

I want to do this :
Read the content of a file line by line and at each line, ask me want to read next line or not, if not, press N - end, if yes, press Y - read next line

For example :

Code:
I love linux verymuch. I want to learn it
Bash shell is not hard but it make
me gonna crazy. Can any one help me
...
I very need suggestion, i know it very easy with somebody else but with me it's not easy to find out.
 
Old 01-15-2009, 09:30 AM   #2
Agrouf
Senior Member
 
Registered: Sep 2005
Location: France
Distribution: LFS
Posts: 1,591

Rep: Reputation: 79
while read line
do
echo $line
echo "read next line?"
read a
[ "$a" = "N" ] && break
done <filename

Last edited by Agrouf; 01-15-2009 at 09:32 AM.
 
  


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
bash shell script read file line by line. Darren[UoW] Programming 51 07-04-2013 08:16 PM
BASH: read every line in the files and use the line as parameters as another program tam3c36 Programming 10 12-07-2010 01:42 PM
bash: read a line from file zokik Linux - General 6 12-10-2008 09:24 AM
php - Read file line by line and change a specific line. anrea Programming 2 01-28-2007 01:43 PM
linux scripting help needed read from file line by line exc commands each line read atokad Programming 4 12-26-2003 10:24 PM


All times are GMT -5. The time now is 03:44 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration