LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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 09-20-2004, 04:58 AM   #1
sorry99
LQ Newbie
 
Registered: Sep 2004
Posts: 1

Rep: Reputation: 0
Unhappy bash script problem


Hi,
i have a problem in creating a bash script in which I redirect the output of a command to a file (ex: ls -a >list.txt) and after I have to read the file list.txt line by line memorizing the path read into a variable. How can I do this last thing? I'd be grateful if anyone would try to chelp me.

Thanks
 
Old 09-20-2004, 07:19 AM   #2
barisdemiray
Member
 
Registered: Sep 2003
Location: Ankara/Turkey
Distribution: Slackware
Posts: 155

Rep: Reputation: 30
You can use a for loop for this;

Code:
declare current_dir;
for directory in `cat list.txt`; do
    let current_dir=$directory;
    echo "current directory is $current_dir";
done
 
Old 09-20-2004, 09:02 AM   #3
Cedrik
Senior Member
 
Registered: Jul 2004
Distribution: Slackware
Posts: 2,140

Rep: Reputation: 242Reputation: 242Reputation: 242
You may want to log path in list.txt file at the same time
with the above, eg :

Say your command is : find /home -name "*.jpg"
Code:
for file in `find /home -name "*.jpg"`; do
    echo $file >> file.txt
    echo "current file is $file"
done
 
  


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
Problem with bash script. cheater1034 Programming 9 11-21-2005 10:29 PM
bash script problem fatbastard spice Linux - General 2 08-24-2005 02:15 AM
bash script problem GATTACA Programming 3 06-13-2005 09:59 AM
Bash script problem kalleanka Programming 2 01-30-2004 11:59 AM
Problem with bash script cowardnewbie Programming 1 10-01-2001 06:53 AM


All times are GMT -5. The time now is 05:35 PM.

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