LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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-16-2008, 08:55 AM   #1
kalimat
Member
 
Registered: Dec 2008
Posts: 30

Rep: Reputation: 0
Variable to refer a file in a folder


Hello!
How can i make a variable in a bash script, to refer each file in a folder,and to switch it to the next file,until the last file of the folder?
thanks
 
Old 12-16-2008, 09:01 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
The typical construction is:

for varname in `ls`; do
stuff
more stuff
done

Those are "backticks" , not single quotes
 
Old 12-17-2008, 02:56 AM   #3
burschik
Member
 
Registered: Jul 2008
Posts: 159

Rep: Reputation: 31
"ls" is not required:

Code:
for file in *
  do whatever
done
 
  


Reply



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
save web page results in a file and a folder. Whats the folder for? geeyathink General 2 01-30-2008 06:57 AM
create a folder/file within a folder using perl indu.a Programming 2 03-07-2007 10:09 PM
how to refer to environment variables in an ant file irfanhab Programming 1 09-12-2005 06:15 AM
Virtual hosts refer to the same document root folder kumu Linux - Software 2 09-04-2004 07:19 PM
how can i default the max folder file size when it create inside a folder antony_csf Linux - Software 1 06-17-2004 02:26 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:37 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
Open Source Consulting | Domain Registration