Results 1 to 4 of 4
Hi, I was thinking of writing a script to segregate my ebooks and put them in their corresponding directory. And i wrote a script which searches for the file with ...
- 09-09-2009 #1
"cannot stat :No such file or directory " error in script
Hi, I was thinking of writing a script to segregate my ebooks and put them in their corresponding directory. And i wrote a script which searches for the file with give key word in the current directory and copies them to a specified directory.
here is the script
but when i run this script i get the error message like the below for all filesCode:if [ $# -eq 0 ] then echo "few arguments supplied" exit 1 fi IFS=, files=`ls -mQ|grep -i $1` for file in $files do file=`echo $file|tr -s '\n' ' '` #echo $file cp $file ~/tmp done
cannot stat ` "Professional Java Development With The Spring Framework (2005).chm" ': No such file or directory
so what am i doing wrong, can u guys help me
thanks in advance
M.Kannan
- 09-09-2009 #2
The problem you are likely having here is that the file:
Professional Java Development With The Spring Framework (2005).chm doesn't exist.
If you were to tab-complete this, you would get:
Professional\ Java\ Development\ With\ The\ Spring\ Framework\ \(2005\).chm
Been a while since i did Bash, but I *THINK* if you quote the $file at the end
That should be fine.Code:cp "$file" ~/tmp
"I am not an alcoholic, alcoholics go to meetings"
Registered Linux user = #372327
- 09-10-2009 #3
yes i tried the same as u said, but still i am getting the same problem, any other suggestions please..
- 09-16-2009 #4Linux Enthusiast
- Join Date
- Aug 2006
- Location
- Portsmouth, UK
- Posts
- 539
Should do the trickCode:grep -l '$1' * | xargs -I{} cp {} ~/tmp/.RHCE #100-015-395
Please don't PM me with questions as no reply may offend, that's what the forums are for.


Reply With Quote