Hi,
Upon executing the below script .....
#!/bin/sh
while read DAYS INDIR OUTDIR
do
find $INDIR -type f "!" -mtime $DAYS -exec mv {} $OUTDIR \;
done </home/Administrator/scripts/tarconfig.sh
I got the following error...
and the files are transferred to out put folder from input folder also, that is script is working fine,but why it shows the error, please guide me ..!!
We need to see the contents of tarconfig.sh to see what data you're feeding into find there. I think you're giving it something which is being interpreted as a -flag somewhere.
Hi,
The content of the tarconfig.sh is below
Have you tried:
find $INDIR -type f "!" -mtime $DAYS | xargs -t -I {} mv "{}" $OUTDIR
It uses an extra pipe, but it prints the command being execute!
---------- Post updated at 15:11 ---------- Previous update was at 14:59 ----------
I copied your script and no error to me!
# more teste.sh tarconfig.sh
::::::::::::::
teste.sh
::::::::::::::
#!/bin/sh
while read DAYS INDIR OUTDIR
do
find $INDIR -type f "!" -mtime $DAYS -exec mv {} $OUTDIR \;
done < ./tarconfig.sh
::::::::::::::
tarconfig.sh
::::::::::::::
16 ./files ./output
You can try a more verbose one, try to put some "echo" inside the while:
# more teste.sh
#!/bin/sh
while read DAYS INDIR OUTDIR
do
echo "[${DAYS}] [${INDIR}] [${OUTDIR}]"
find $INDIR -type f "!" -mtime $DAYS -exec mv {} $OUTDIR \;
done < ./tarconfig.sh
felipe.vinturin:
Have you tried:
find $INDIR -type f "!" -mtime $DAYS | xargs -t -I {} mv "{}" $OUTDIR
It uses an extra pipe, but it prints the command being execute!
Hi,
I have tried this also , the best thing that it shows on console also the files beig moved, but the same warnings...
is still being shown at my cywgin console...
Please, try this one:
#!/bin/sh -x
while read DAYS INDIR OUTDIR
do
echo "[${DAYS}] [${INDIR}] [${OUTDIR}]"
find ${INDIR} -type f -mtime ${DAYS} -exec mv {} ${OUTDIR} \;
done < ./tarconfig.sh
You can see two differences in this one:
-----> "#!/bin/sh -x" in the first line (you can use it as "set -x"), more verbose
-----> All variables enclosed with: "${}"
I also tried in my cygwin and no error!
---------- Post updated at 15:29 ---------- Previous update was at 15:28 ----------
You will see something like:
$ ./teste.sh
+ read DAYS INDIR OUTDIR
+ echo '[0] [./files] [./output]'
[0] [./files] [./output]
+ find ./files -type f -mtime 0 -exec mv '{}' ./output ';'
+ read DAYS INDIR OUTDIR
I hope it helps!
felipe.vinturin:
Please, try this one:
#!/bin/sh -x
while read DAYS INDIR OUTDIR
do
echo "[${DAYS}] [${INDIR}] [${OUTDIR}]"
find ${INDIR} -type f -mtime ${DAYS} -exec mv {} ${OUTDIR} \;
done < ./tarconfig.sh
You can see two differences in this one:
-----> "#!/bin/sh -x" in the first line (you can use it as "set -x"), more verbose
-----> All variables enclosed with: "${}"
I also tried in my cygwin and no error!
---------- Post updated at 15:29 ---------- Previous update was at 15:28 ----------
You will see something like:
$ ./teste.sh
+ read DAYS INDIR OUTDIR
+ echo '[0] [./files] [./output]'
[0] [./files] [./output]
+ find ./files -type f -mtime 0 -exec mv '{}' ./output ';'
+ read DAYS INDIR OUTDIR
I hope it helps!
so shall I try this latest one in my main script file the code below...
$ ./teste.sh
+ read DAYS INDIR OUTDIR
+ echo '[0] [./files] [./output]'
[0] [./files] [./output]
+ find ./files -type f -mtime 0 -exec mv '{}' ./output ';'
+ read DAYS INDIR OUTDIR
rahul125:
so shall I try this latest one in my main script file the code below...
$ ./teste.sh
+ read DAYS INDIR OUTDIR
+ echo '[0] [./files] [./output]'
[0] [./files] [./output]
+ find ./files -type f -mtime 0 -exec mv '{}' ./output ';'
+ read DAYS INDIR OUTDIR
No. The script is:
#!/bin/sh -x
while read DAYS INDIR OUTDIR
do
echo "[${DAYS}] [${INDIR}] [${OUTDIR}]"
find ${INDIR} -type f -mtime ${DAYS} -exec mv {} ${OUTDIR} \;
done < ./tarconfig.sh
The other part is the output of the script!
Putting it in quote tags instead of code tags means it disappears when I quote it.
Is that the entire file?
Hi,
The content of the tarconfig.sh is below
5 /home/Administrator/files /home/Administrator/output
yeah I will take care in futoure to put into code tags..Thanks