Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sat 25 Apr 2015, 19:36
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
sh/bash -- find all files with the word java in them
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [5 Posts]  
Author Message
s243a

Joined: 02 Sep 2014
Posts: 135

PostPosted: Sun 19 Apr 2015, 21:42    Post subject:  sh/bash -- find all files with the word java in them  

This is my first attempt at a bash or an sh script

Code:

for aFile in `find /etc`; do
  found=0
  #echo "Entering $aFile"
  for line in `grep '^.*java.*$' -i -x $aFile`; do
    if [ $found -eq 0 ]; then
       echo "File = $aFile"
      let found=1
    fi
    #echo "Line = $line"
  done
done


here is the output:

Code:

File = /etc/hosts
grep: /etc/xdg/menus/applications-merged/The: No such file or directory
grep: Free: No such file or directory
grep: Network: No such file or directory
grep: Project.menu: No such file or directory
File = /etc/mime.types
grep: /etc/init.d/binfmt-support: No such file or directory
File = /etc/modprobe.d/puppy.conf
File = /etc/hiawatha/mimetype.conf
File = /etc/gitweb.conf
File = /etc/X11/xkb/symbols/pc/in
File = /etc/services


**Notes
1. I couldn't figure out how to use the variables true and fase so I used one and zero instead.
2. grep seems to give an error when passed a broken symbolic link. I need a way to suppress this.

If your curious why I wrote the script. I was wondering where the java library search path might be stored. My puppy version is "precise". I recently installed libsvn-java (i.e. javaHL) which is a library required for eclipse to import from a git repository. The puppy package manager installed this at:

/usr/lib/jni

This was not in the java search path as seen by eclipse. According to:
http://subclipse.tigris.org/wiki/JavaHL

I can tell eclipse where this is by including the following line in the eclipse.ini file:
Code:

-Djava.library.path=/usr/lib/jni


However, if you want to include the locations within LD_LIBRARY_PATH as well then one should instead use:
Code:

-Djava.library.path="${workspace_loc:project}\lib;${env_var:PATH}"

according to:
http://stackoverflow.com/questions/661320/how-to-add-native-library-to-java-library-path-with-eclipse-launch-instead-of

Therefore, I think I should have searched instead for "LD_LIBRARY_PATH". As for making perminant environmental variable changes

In another thread they suggested editing either "/etc/profile.local" or "/etc/profile.d/". Maybe I'll think about how to do this.
Back to top
View user's profile Send private message 
amigo

Joined: 02 Apr 2007
Posts: 2341

PostPosted: Mon 20 Apr 2015, 01:03    Post subject:  

Much, much, much faster and shorter:
grep '^.*java.*$' /etc/*
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 650
Location: Japan

PostPosted: Mon 20 Apr 2015, 01:17    Post subject:  

grep -rl java /etc/*
Back to top
View user's profile Send private message 
Uten


Joined: 29 Jan 2008
Posts: 87

PostPosted: Mon 20 Apr 2015, 12:57    Post subject:  

Hi @s243a,
Congrats with a nice first attempt at a script. I suspect you have some knowledge in programing in another language so therefor I will just point you to som nice resources in shell/bash scripting.
http://www.grymoire.com/Unix/ Also take a look at the sed and awk section.
http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.htmlBrows trough and easy lookup.
http://www.tldp.org/LDP/abs/html/index.html atleast if you include it in a search to find the right page.
I keep a copy of the two last ones on my lookal disk to do quick searches.

Best regards
Uten
Back to top
View user's profile Send private message 
s243a

Joined: 02 Sep 2014
Posts: 135

PostPosted: Today, at 19:26    Post subject:  

Uten wrote:
Hi @s243a,
Congrats with a nice first attempt at a script. I suspect you have some knowledge in programing in another language so therefor I will just point you to som nice resources in shell/bash scripting.
http://www.grymoire.com/Unix/ Also take a look at the sed and awk section.
http://www.tldp.org/LDP/Bash-Beginners-Guide/html/index.htmlBrows trough and easy lookup.
http://www.tldp.org/LDP/abs/html/index.html atleast if you include it in a search to find the right page.
I keep a copy of the two last ones on my lookal disk to do quick searches.

Best regards
Uten


I just found today what looks like a great linux reference:
http://www.gnu.org/software/bash/manual/bashref.html#Shell-Parameter-Expansion
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [5 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0866s ][ Queries: 11 (0.0351s) ][ GZIP on ]