You did not pass the proper output to xargs.
Filenames are needed, and you passed entire output of ls -lrt | grep .. command.
What would happen if you issue cp against one line of input ?
A cp would output an error cp: invalid option -- 'w'
In reality, you got unpredictable result,only luck and coincidence helped no damage is done.
You can achieve desired output using awk, cut or similar tools.
But that code can break on filenames with spaces, and possibly others.
If you are sure those will not exist...
So, for travesting filesystem and doing operations the safest tools would be find and xargs with print0 and option -0.
Hi All,
i'm trying to copy the 1.txt files (sample files) in to different path location using the below command.
But it is not copying the files , when i tried for single location able to copy the file.
can any one please assist here.
Please find the below path :-
/ckr_mkr1/licencekey... (2 Replies)
Hi,
I need to write a script the has to copy the files from folders and subfolders to the same folder structure located in another location.
Ex:
mainfolder1
file1,file2,file3 subfolder1(file1,etc) subfolder2(file1,etc) to another folder location of same folder structure.
rsync is not... (7 Replies)
A) I would like to achive following actions using shell script. can someone help me with writing the shell script
1) Go to some dir ( say /xyz/logs ) and then perform find operation in this dir and list of subdir using
find . -name "*" -print | xargs grep -li 1367A49001CP0162 >... (1 Reply)
Hi all,
I need a suggestion in the following case,
I have folder1, folder2 ,folder3 and file1 inside /home/test/source ..
I need to copy all the folders and files to another location /home/test/destination
Pls suggest any way to program this in C++.. :confused: (1 Reply)
Hi, i am new to shell scripting. i have a requirement to copy the files from a windows shared location( vendor will place the files here) to Linux server( my Informatica will pick the files from this location). Files should be loaded in the order in which they were placed in windows box.(Based on... (1 Reply)
Hi to all here ,
Excuse me for the lamer question but I need UNIX command for copying List of Files Under Different File Names !
for example I have this list:
new_001.jpg
new_002.jpg
new_003.jpg
.....
I want to copy all files that start with "new_" to the same directory but under... (7 Replies)
I want equivalent of ftp in sftp for listing of files into local machine from sftp location.
ftp>ls -l list.txt
the above creates a file list.txt in the local machine's current directory.
sftp>ls -l list.txt
it is giving
Couldn't stat remote file: No such file or directory
is there... (1 Reply)
Hello All,
I would like to download a list of files from a remote server to my local machine preserving the path i.e, create a similar directory tree.
ex:
files on the remote machine with path
/remoteserver/005_S_0221/mpr/m1/I72128/dat/06A515T.dat... (3 Replies)
I have two servers. I would like to copy some files from one directory on server A into the same directory on server B.
Its not all the files in in the directory, just some of them.
Is there a way to make a file list in a txt file and then somehow copy all the files in that list in one go to... (6 Replies)
I have a text list of about 3,000 file names (image files), which exist on a server and that I want to copy over to another location. I understand the Unix cp code, but what's the string to have it copy multiple files based on an external list?
Many thanks! (4 Replies)