LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 12-25-2005, 04:52 PM   #1
symo0009
LQ Newbie
 
Registered: Dec 2005
Posts: 12

Rep: Reputation: 0
for loop only works properly on first loop


in the following batch file the for loop performs the correct function on the first loop and then on the following loops it will only echo $entry... how do i make it output
`pwd`/"$entry"
every time it loops?


SCRIPT-------------------

for entry in "`cat list1.list`"
do

echo `pwd`/"$entry"

done


OUTPUT-------------------

/mnt/sda5/music/"song 1"
"song 2"
"song 3"
"song 4"
"song 5"
 
Old 12-25-2005, 05:17 PM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
Code:
#!/bin/bash

while read entry ; do
    echo $PWD/"$entry"
done <list1.list
 
  


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
while loop or for loop? mijohnst Programming 18 11-21-2005 04:48 PM
No loop# SeaSharp Linux - Newbie 3 09-06-2005 08:14 PM
WHILE LOOP in 'C' ']['HeBroken Programming 4 10-29-2004 01:42 AM
for loop klfreese Programming 16 08-11-2003 11:09 AM
help with the following C loop ..... purpleburple Programming 12 08-06-2002 10:32 PM


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