How to copy files from one location to another using xargs??
Hello Experts,
I need to copy files from one location to another using xargs.
Tried something like this (In Ubuntu & Solaris ).
But every time i run this, a weird error pops up.
Files to be copied have long names
but they cant be altered either and i have tried most of the things in the internet.
#Helpneeded
Last edited by Scott; 04-25-2014 at 03:05 PM..
Reason: Use code tags, please...
If you use the -0 option to xargs, you need to -print0 from find. And, the {} in xargs works only if you specified the replace_string with the -I option.
I need to copy files from one location to another using xargs.
Tried something like this (In Ubuntu & Solaris ).
But every time i run this, a weird error pops up.
Files to be copied have long names
but they cant be altered either and i have tried most of the things in the internet.
#Helpneeded
Note that unless you happen to be sitting in /home/emd/Desktop when you run this script, mkdir will create 1234 in whatever directory you're sitting in; not necessarily /home/emd/Desktop.
It has already been mentioned that if you use -0 on xargs, you need to use -print0 on find; but neither of these are available on Solaris systems (unless you have the GNU utilities installed). But, unless there are whitespace characters (<space>, <tab>, and <newline>) or quotes (<single-quote> or <double-quote>) in your filenames, you don't need them (and your sample names don't appear to need them).
Since you are using -type f in find, cp won't be given any directories as operands (other than the target directory given as the last operand), the -r option is a no-op.
But, with the xargs -I or -i option, one of which is needed if you don't want xargs to add the pathnames read from standard input to the end of the constructed cp command line; xargs will only pass one pathname from standard input as an operand to cp at a time. So, xargs is a waste of time. A simpler script that should work on both Ubuntu and Solaris systems is:
These 2 Users Gave Thanks to Don Cragun For This Post:
Hello everyone, Im super new to coding but increasingly in need of it at work. Im have task stacked because of this problems, that I cannot figure out how to solve looking on the internet after trying many many things that looked similar to me.
I have multiple data files of the form (see below).... (2 Replies)
Hello All,
Since i'm relatively new in shell script need your guidance.
I'm copying files manually based on a specific word in a file name and its extension and then moving it into some destination folder.
so if filename contains hyr word and it has .md and .db extension; it will move to TUM/HYR... (13 Replies)
Hello there wonderful people,
I am running on Solaris 10 and with the following ksh version:
strings /bin/ksh | grep Version | tail -2
@(#)Version M-11/16/88i
Suppose I want to copy files that end in _v2 from underneath /dir1/dir2/save directory to /dir1/dir2. Basically, what I’m... (12 Replies)
Discussion started by: ejianu
12 Replies
4. Post Here to Contact Site Administrators and Moderators
Hi guys...please any one help me ....
how to copy files from source to target location
if 5 files copied successfully out of 10 files then implement success=10
and if remaining 5 files not copied successfully then count error=5
how to implement this condition with in loop
i need code linux... (0 Replies)
I have below files in one location /test/files and also for each dates there are similar files
A20130924.0000-0005_file1
A20130924.0000-0005_file2
A20130924.0005-0010_file1
A20130924.0005-0010_file2
.
.
.
A20130924.2355-0000_file1
A20130924.2355-0000_file2
If i execute the script like... (4 Replies)
Hi Gurus,
I am a newbie to shell scripting and I am facing a problem right now.I have to automate the copy of files based on a priority.The scenario is as below:
1) There will be files from Mon-Fri with Mon file being named as abc_def_01_YYYYMMDD and Tue file being abc_def_02_YYYYMMDD and so... (4 Replies)
:EDIT:
I think my post name should have been labeled: how to copy files and record original file location. not "retain".
Hello, this is my first post! I searched the forums a lot before posting, but was unable to answer my question.
Here's my problem:
There are several hundred text files... (4 Replies)
Hello all! I am trying to create a script that will copy files from one location, to another but only folders that are filled with thumbnails to an exact directory replica in the second location. For example:
/images/2012/01/19/Event/Photographer/thumbnails
to
... (4 Replies)
Create a script that copies files from one specified directory to another specified directory, in the order they were created in the original directory between specified times. Copy the files at a specified interval. (2 Replies)
I need help in forming a script to copy files from one location which has a sub directory structure to another location with similar sub directory structure,
say location 1,
/home/rick/tmp_files/1-12/00-25/
here 1-12 are the number of sub directories under tmp_files and 00-25 are sub... (1 Reply)