Skip to main content

I'm working on a script to copy files at the Linux level from one folder to another. The commands are:

SH -c"find CIF.IMAGES -type f -exec mv {} /bl1/newfolder \\;"

CIF.IMAGES is a folder in my account and I'm trying to move all of the files to the newfolder in /bl1. The issue is that the paragraph interpreter is seeing the "\\" as an unmatched quote and fails, so nothing gets moved.

Suggestions?



------------------------------
Jeff Teter
Woodforest National Bank
The Woodlands, TX
------------------------------

I'm working on a script to copy files at the Linux level from one folder to another. The commands are:

SH -c"find CIF.IMAGES -type f -exec mv {} /bl1/newfolder \\;"

CIF.IMAGES is a folder in my account and I'm trying to move all of the files to the newfolder in /bl1. The issue is that the paragraph interpreter is seeing the "\\" as an unmatched quote and fails, so nothing gets moved.

Suggestions?



------------------------------
Jeff Teter
Woodforest National Bank
The Woodlands, TX
------------------------------
Jeff,

We've gotten around that (and similar issues) by putting the unix commands into unix-level scripts, and then just calling the script name in the SH -c command.

Brian

I'm working on a script to copy files at the Linux level from one folder to another. The commands are:

SH -c"find CIF.IMAGES -type f -exec mv {} /bl1/newfolder \\;"

CIF.IMAGES is a folder in my account and I'm trying to move all of the files to the newfolder in /bl1. The issue is that the paragraph interpreter is seeing the "\\" as an unmatched quote and fails, so nothing gets moved.

Suggestions?



------------------------------
Jeff Teter
Woodforest National Bank
The Woodlands, TX
------------------------------
Hi Jeff,
I ran a similar command with UniVerse 11.3.x on Linux and did not have an issue. Do you have the specific error? I'm wondering if one of the file names in the directory has an impact? The syntax you provided does look valid.

>SH -c "find BP -type f -exec mv {} /disk1/newBP \\;"

>COUNT BP

0 records counted.
>
>SH
[root@dentrp morrisn]# ls -l /disk1/newBP
total 64
-rwxr-xr-x 1 root root 5 May 4 13:16 A?\\R
-rwxr-xr-x 1 root root 108 Mar 24 2021 CONVTEST
-rwxr-xr-x 1 root root 34 Apr 15 06:28 DMA
-rwxr-xr-x 1 root root 34 Apr 15 06:28 DMB
-rwxr-xr-x 1 root root 102 Nov 5 07:34 DT
-rwxr-xr-x 1 root root 80 Apr 15 06:19 DTM
-rwxr-xr-x 1 root root 78 Apr 13 09:19 DTTEST
-rwxr-xr-x 1 root root 101 Apr 13 10:19 DTTEST2
-rw-r--r-- 1 root root 1347 Jan 28 09:20 ENCODE.TEST
-rw-r--r-- 1 root root 3910 Feb 18 2021 GTEST
-rwxr-xr-x 1 root root 20 Nov 15 16:56 GS2
-rwxr-xr-x 1 root root 104 Jan 11 13:45 INPUTTEST
-rwxr-xr-x 1 root root 332 Mar 15 10:07 MASTER
-rwxr-xr-x 1 root root 103 Feb 18 2021 OUT.TX.SUBR
-rw-r--r-- 1 root root 873 Feb 2 14:34 READ.TEST
-rwxr-xr-x 1 root root 274 Jan 29 2021 UPDATE.TESTFILE1
[root@dentrp morrisn]#

Thanks,

Neil

------------------------------
Neil Morris
Universe Advanced Technical Support
Rocket Software
------------------------------
Jeff,

We've gotten around that (and similar issues) by putting the unix commands into unix-level scripts, and then just calling the script name in the SH -c command.

Brian
Thanks, Brian! 

That is a good strategy and I was able to make it work.

------------------------------
Jeff Teter
Woodforest National Bank
The Woodlands, TX
------------------------------
Jeff,

We've gotten around that (and similar issues) by putting the unix commands into unix-level scripts, and then just calling the script name in the SH -c command.

Brian
Hi Jeff,

You could always use the + (plus) terminator within the find command
It's more efficient as it does not fork() a copy of the exec command for every file, the downside is it could end up a very large command line that could break the system maximum so may not be suitable.

This would negate the requirement for the \\ (backslash) in the first place.

>find . -exec echo {} +
. ./a ./b ./c ./d
>find . -exec echo {} \\;
.
./a
./b
./c
./d

------------------------------
Mark Copp
Infrastructure Design
Travis Perkins Trading Company Ltd
Northampton GB
------------------------------

I'm working on a script to copy files at the Linux level from one folder to another. The commands are:

SH -c"find CIF.IMAGES -type f -exec mv {} /bl1/newfolder \\;"

CIF.IMAGES is a folder in my account and I'm trying to move all of the files to the newfolder in /bl1. The issue is that the paragraph interpreter is seeing the "\\" as an unmatched quote and fails, so nothing gets moved.

Suggestions?



------------------------------
Jeff Teter
Woodforest National Bank
The Woodlands, TX
------------------------------
Try putting two backslashes in front of the backslash. It is probably
interpreting the backslash to take the semicolon literally, so by the time
the find command gets there, the backslash is gone.

Putting two backslashes will cause the script to put a literal backslash in
the command, so the find command will have a backslash to delimit the
semicolon.

SH -c"find CIF.IMAGES -type f -exec mv {} /bl1/newfolder \\\\\\;"

Mark A. Baldridge
467 County Road 2011
Nacogdoches, TX 75965-0447
413 841 3892