The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
whats wrong in this pls help how to take $i value ? santosh1234 Shell Programming and Scripting 3 12-26-2008 09:28 AM
tell me whats wrong with this nadman123 Shell Programming and Scripting 1 04-14-2008 11:58 PM
tell me whats wrong in this? nadman123 Shell Programming and Scripting 1 04-10-2008 01:11 AM
Whats wrong with this script? kayarsenal Shell Programming and Scripting 2 08-25-2006 09:58 AM
whats wrong with this awk??? george_ Shell Programming and Scripting 5 04-04-2006 04:58 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-26-2009
crackthehit007 crackthehit007 is offline
Registered User
  
 

Join Date: Feb 2009
Location: Pune/Banagalore
Posts: 71
whats wrong with this find statement ?

cmd="find /a/technologies -name '*.jar' | grep \"Tuning/specificloader/lib\""
echo $cmd
for index in `$cmd`

do
SL_JARS="${SL_JARS}:${index}"
done


gives error ==>
find: paths must precede expression
Usage: find [-H] [-L] [-P] [path...] [expression]

but

for index in `find /a/technologies -name *.jar | grep "Tuning/specificloader/lib"`

do
SL_JARS="${SL_JARS}:${index}"
done


is working fine
  #2 (permalink)  
Old 03-26-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,259
Maybe better fill the variable like an array like this:
Code:
list="`find /a/technologies -name '*.jar' -print | grep \"Tuning/specificloader/lib\"`"
I added backticks in front and at the end of the command string so it will be substituted right there and assigned to the varaiable like a list.
You will have problems using it this way when you have blanks in file or directory names anyway.
I also added a -print since some versions of find might want it to print output in terms of portability.

Then when using it in the for-loop you just insert `$cmd` vs. $list.
  #3 (permalink)  
Old 03-26-2009
namishtiwari namishtiwari is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2007
Location: Bangalore
Posts: 377
Hi,

When you are substituting the output of a command to a varibale you must use the backticks ( The one below the ~ sign in keyboard).

so the substitution will be like this--

Code:

cmd="`find /a/technologies -name '*.jar' | grep \"Tuning/specificloader/lib\"`"
Thanks
NT
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0