The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
String search - Command to find second occurance saurabhsinha23 UNIX for Dummies Questions & Answers 5 12-06-2007 05:03 PM
Problems with find command lodey UNIX for Dummies Questions & Answers 4 10-27-2007 04:47 AM
Unix find command to print directory and search string princein UNIX for Dummies Questions & Answers 4 03-06-2007 05:46 AM
Looking for command(s)/ script to find a text string within a file wrwelden Shell Programming and Scripting 5 11-22-2006 09:53 PM
ctrl-c: not escaping command dangral UNIX for Dummies Questions & Answers 3 06-23-2004 01:36 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 12-03-2005
Registered User
 

Join Date: Dec 2005
Location: Windsor, Ont Canada
Posts: 13
find: problems escaping printf-command string

Hi Folks!

Can you help me with this find -printf command. I seem to be unable to execute the printf-command from my shell script. I'm confused:

My shell script snippet looks like this:
Code:
#!/bin/sh
..
COMMAND="find ./* -printf '%p %m %s %u %g \n'"
echo "Command: ${COMMAND}"
${COMMAND} > ${ARCHIVE_DIR}/${CURRENT_FILE}
With or without the single quotes enclosing the %p, etc, I get this error message:
Code:
Command: find ./* -printf '%p %m %s %u %g \n'
find: paths must precede expression
At the command line (bash), the command works. Further-more it only works for me with the single quotes enclosing the printf-command string.

Look forward to your replies
Grahamb

Using Fedora2.54 with bash; and #!/bin/sh for shell execution
Reply With Quote
Forum Sponsor
  #2  
Old 12-04-2005
Registered User
 

Join Date: Dec 2005
Location: Windsor, Ont Canada
Posts: 13
Question That dammed substitution!

Hi You Guys!

I'm sure most of you have an answer to this one. I'm trying to do a work around on the problem above, but get held up elsewhere!!!!! So can't avoid this problem.

Here's my next stopper:
Code:
COMMAND="ls -la --full-time `find ./* -type f` "
${COMMAND} | awk '''{ print '$NF' '$0' }''' >> ${ARCHIVE_DIR}/${TMP_FILE}
The log file shows this error:
Code:
+ awk '{ print  /usr/share/scripts/security_check.sh }'
I'm half way there. I have the '{ }' parts carried to the command line. BUT the "$NF" is substituted to be blank and "$0" is substitued as the calling program!!

When I put \$NF inside the awk-brackets the "\" gets sent to the command line, eg:
Code:
+ awk '{ print  \$NF \$0 }'
Close but not close enough!

Can u help? Any ideas? Any links to help me?

regards
GrahamB
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 05:53 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0