Re: Quotes problem ?
Hello , Eric: Sorry, I forgot to mention the platform. It is a Sun 250 with Solaris 8.Thank you anyway. Paul: It worked with the changes you told me. Thank you very much.I still have a question anyway: You said that line cd $path should be better with quotes to avoid problems with dir names containing spaces, so did you mean this? cd $path -- View this message in context: http://www.nabble.com/Quotes-problem---tf2952284.html#a8275269 Sent from the Gnu - Bash mailing list archive at Nabble.com. ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
Re: Quotes problem ?
Markos [EMAIL PROTECTED] wrote: You said that line cd $path should be better with quotes to avoid problems with dir names containing spaces, so did you mean this? cd $path Yes. paul ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
Quotes problem ?
Hello , I'm having problems with the script I send below. Problem description: I'm trying to run a script called logo_changer.sh that creates a file called results containing different lines and every line is a path to a dir where the logo_1.gif file is located. After the results file is filled, I try to read it line by line, go to every dir refered in that line, check the size of the logo_1.gif file in that dir and then store both path and size of every logo_1.gif file founded on the system in a file called report. I run bash -x logo_changer.gif and the result is this: ... [cut some lines here with same message] ... + sed -n '$line_numberp' /tmp/results /tmp/logo_changer.sh: : No such file or directory + cd + pwd + ls -go logo_1.gif logo_1.gif: No such file or directory + awk '{print $3}' /tmp/size + echo + line_number=line_number+1 + i=6 + '[' 6 -le 5 ']' can anybody reproduce the problem and tell me what is wrong? #!/usr/local/bin/bash #Execute it from /ecas #We search for the string logo_1.gif and store the resulting paths in results_1 find . -name logo_1.gif /tmp/results_1 #Delete logo_1.gif string from every line in results_1, #leaving only the path to prepare for cd step sed 's/logo_1.gif//' /tmp/results_1 /tmp/results #Initialization of variables i=1 line_number=1 #every line (dir path) stored in results path= while [ $i -le 5 ]#In fact it contains more than 5 of course... do #Start taking line by line and store it the path variable sed -n $line_numberp /tmp/results $path #We change to dir stored in the path variable cd $path #Print actual path into /tmp/report to check later pwd /tmp/report #Take the size of logo_1.gif file from current dir ls -go logo_1.gif /tmp/size #Print actual file size into /tmp/report to check later awk '{print $3}' /tmp/size /tmp/report #Print a blank line at the report after every path and size to see things clearer echo /tmp/report #Update variables line_number=line_number+1 i=$[$i+1] done -- View this message in context: http://www.nabble.com/Quotes-problem---tf2952284.html#a8256981 Sent from the Gnu - Bash mailing list archive at Nabble.com. ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
Re: Quotes problem ?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 According to Markos on 1/10/2007 5:49 AM: Hello , I'm having problems with the script I send below. ... + sed -n '$line_numberp' /tmp/results /tmp/logo_changer.sh: : No such file or directory + cd + pwd + ls -go logo_1.gif logo_1.gif: No such file or directory You failed to mention your platform. However, my guess would be that you are on cygwin, and that your script has CRLF line endings even though you told cygwin to respect CR as a literal character rather than ignoring it (because you used a binary instead of a text mount). The output messages resemble a rash of similar messages reported to the cygwin list for the same root cause. If my ESP is strong enough to have correctly diagnosed your problem, then the fix is simple - remove the CR from your script by running d2u on it. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] volunteer bash port maintainer for cygwin -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFpOLe84KuGfSFAYARAnRoAKCL9G2+OB3f0WTUTsclijk3nq8QHgCgtGsb wREx7tNwrcT5t7eQAXxNY6k= =4/zK -END PGP SIGNATURE- ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash
Re: Quotes problem ?
Markos [EMAIL PROTECTED] wrote: #Delete logo_1.gif string from every line in results_1, #leaving only the path to prepare for cd step sed 's/logo_1.gif//' /tmp/results_1 /tmp/results This would be more precisely expressed as: sed 's:/logo_1\.gif$:/:' /tmp/results_1 /tmp/results If you happen to have a directory contining logo_1.gif in its name, your version won't do what you want. sed -n $line_numberp /tmp/results $path doesn't do what you want. It redirects the output of a command to a file. If you want to store the output in a shell variable, use this: path=$(sed -n $line_numberp /tmp/results) #We change to dir stored in the path variable cd $path Quotes would be useful here, in case you have a directory name containing spaces. paul ___ Bug-bash mailing list Bug-bash@gnu.org http://lists.gnu.org/mailman/listinfo/bug-bash