Rename Files in remote directory

Hi All,

I am creating a script which will connect to remote server with ssh and perfom below.
- Search in a directory
- Search for a pattern
- Check the size if greater than the size_limit rename the file.

Below is the code i have written.

ssh user@host <<EOF

find /tmp -name "abc*log" -type f -size +100c | awk '{print "mv " $0 " "$0"_BKUP" }' |sh

EOF

But it is not able to rename.

Below is the error encountered

mv: cannot stat `/tmp/abc1.log': No such file or directory

Kindly help me in identifying the issue.

Please use code tags as required by forum rules!

Show evidence that file abc1.log exists in /tmp on the remote node.

Below are the list of files i am searching for. I have used abc*log as example

ls -rlt /export/SideSupport/logs/logs_backup/W_DDAServer*
-rw-r--r--   1 sideapp  sidegrp      870 Jun 30 04:32 /export/SideSupport/logs/logs_backup/W_DDAServer.062914-011602
-rw-r--r--   1 sideapp  sidegrp       81 Jun 30 04:32 /export/SideSupport/logs/logs_backup/W_DDAServer.062714-220103
-rw-r--r--   1 sideapp  sidegrp       81 Jun 30 04:32 /export/SideSupport/logs/logs_backup/W_DDAServer.062714-220005
-rw-r--r--   1 sideapp  sidegrp      870 Jun 30 04:32 /export/SideSupport/logs/logs_backup/W_DDAServer.062214-011602
-rw-r--r--   1 sideapp  sidegrp       81 Jun 30 04:32 /export/SideSupport/logs/logs_backup/W_DDAServer.062014-220103
-rw-r--r--   1 sideapp  sidegrp       81 Jun 30 04:32 /export/SideSupport/logs/logs_backup/W_DDAServer.062014-220002
-rw-r--r--   1 sideapp  sidegrp      870 Jun 30 04:32 /export/SideSupport/logs/logs_backup/W_DDAServer.061514-011602

You have been asked before to use CODE tags. It's not hard to do and it makes code/data far easier to read. Highlight the text and press the CODE icon, or manually wrap the text in &

Anyway, I'm assuming that this is a listing from the remote server you are connecting to with ssh. Could you try:-

find /tmp -name "abc*log" -type f -size +100c|while read file
do
   printf "mv $file ${file}_BKUP\n"
   mv $file ${file}_BKUP
done

Does that help at all? The printf just produces some trace output. You can remove it if you are happy it works.

Robin

no i can see the same error

Please post up the shortest script you have that reproduces this in & tags along with the output.

It would be useful if the script had some tracing in it to show what it is actually trying to do so we don't theorise and miss something.

Thanks,
Robin