Latest LQ Deal: Linux Power User Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 11-04-2003, 04:21 AM   #1
Registered: Oct 2002
Location: Ayrshire, Scotland
Distribution: Suse(home) RHEL (Work)
Posts: 263

Rep: Reputation: 30
Running a script on every file in a directory

Is there some way a bash script can pick up every filename in a directory and run an operation on it, or do I have to pipe the contents of an 'ls' to an array, create a loop, and perform the operation? I don't want to create more work than I need to...

Has anyone got a script that's an example of this that I could borrow?

Old 11-04-2003, 05:05 AM   #2
Registered: Oct 2002
Location: Ayrshire, Scotland
Distribution: Suse(home) RHEL (Work)
Posts: 263

Original Poster
Rep: Reputation: 30
Solved it myself...


for i in `ls`
<commands here>

Old 11-04-2003, 02:34 PM   #3
jim mcnamara
Registered: May 2002
Posts: 964

Rep: Reputation: 36
find . -name \* -exec myshellscriptname {} \;

where myshellscriptname expects a filename as an argument


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
script execution - file/directory permission issue serksimper Linux - Enterprise 1 08-10-2005 03:01 PM
Shell script to copy file name with part of directory Transition Linux - General 5 01-18-2005 05:40 PM - No such file or directory - ??? ilhbutshm Programming 5 05-26-2004 10:26 AM
Run script during file copy or create in directory neranjana Linux - General 1 01-13-2004 06:57 AM
Running a script file johnlb Linux - Newbie 2 02-19-2003 02:17 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:42 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration