LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] quick bash loop?

[ILUG] quick bash loop?

Jean Francois Bucas jfbucas at stp.dias.ie
Tue May 22 16:58:44 IST 2012


"find -exec" is a very good solution, especially for recursion, but
since the question is on a bash loop:

for f in *; do
   if [ -f "$f" ]; then
     java -jar j.jar "$f"
   fi
done


or if you want a wrapper for your jar program:

while [ -n "$1"]; do
  if [ -f "$1" ]; then
     java -jar j.jar "$1"
  fi
  shift
done

On 05/22/12 16:31, Thomas Pedoussaut wrote:
> find -exec is your friend
> 
> find /wherever -type f -mtime XXX ... -exec mycommand {} \;
> 
> On 22/05/12 17:15, Bernhard Rohrer wrote:
>> Hi guys
>>
>> may I ask for help with bash again please? I have a .jar that when told to work on * only works on the first file in the directory. 
>> Can anybody suggest a simple way to make it munch through the whole
directory?
>>
>> Thanks
>>
>> /Bernhard
>>
>> --

-- 
Jean-Francois Bucas
IT System Administrator
School of Theoretical Physics
Dublin Institute for Advanced Studies
10 Burlington Road
Dublin 4
Tel. +353 1 614 0132


More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell