Sponsored Content
Full Discussion: Copying files automatically
Top Forums UNIX for Dummies Questions & Answers Copying files automatically Post 302430764 by Corona688 on Friday 18th of June 2010 03:48:35 PM
Old 06-18-2010
Problem with xargs and mv is mv expects the destination on the end. But xargs tacks new arguments onto the end: ls | xargs mv destination will run mv destination file1 file2 file3 file4 which will complain "file4 is not a directory". (Or, if file4 is a directory, will mysteriously vanish everything into it Smilie )

Fortunately mv has an option that lets you put the destination before: -t.

Code:
find | xargs mv -t destination

will make it run mv -t destination file1 file2 file3 file4, which is what you need.

find * is redundant, by the way. The way to avoid too many arguments is to not use too many arguments, so don't do globbing at all. Just find by itself will find all files and directories in ./, including ./. You can restrict that further by giving it a specific place to look inside: find ./dir or telling it what kinds of files to find: find -type f (f is files, d is dirs), or certain names: find -iname '*.zip' or telling it a minimum depth to start at: find -mindepth 1 (depth 0 includes ./, depth 1 only includes its contents, etc.) You can keep adding more options to narrow it down to what you need. See man find for full details.

Last edited by Corona688; 06-18-2010 at 05:13 PM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How can I automatically find important files???

how can I automatically check if important files exist in a directory and if not, automatically put the important files where they are needed say, I want to put .bashrc and a dozen other important files like it into every user's directory, how can I do this??? how do I check every user's... (4 Replies)
Discussion started by: TRUEST
4 Replies

2. UNIX for Dummies Questions & Answers

Automatically copying files from server to local drive?

I would like automate the process of copying some logs files from a server to my local hard drive at a set time each week/day. I don't really know anything about creating and scheduling jobs. Is this something I could setup relatively easily? I would like to automatically copy all the logs... (1 Reply)
Discussion started by: Sepia
1 Replies

3. UNIX for Advanced & Expert Users

copying of files by userB, dir & files owned by userA

I am userB and have a dir /temp1 This dir is owned by me. How do I recursively copy files from another users's dir userA? I need to preserve the original user who created files, original group information, original create date, mod date etc. I tried cp -pr /home/userA/* . ... (2 Replies)
Discussion started by: Hangman2
2 Replies

4. Shell Programming and Scripting

Shell script to automatically download files

I am new to shell scripting and need to write a program to copy files that are posted as links on a specific url. I want all the links copied with the same file name and the one posted on the webpage containing the url onto a specific directory. That is the first part. The second part of the script... (2 Replies)
Discussion started by: libertyforall
2 Replies

5. Shell Programming and Scripting

Files copying - [ Listed files alone. ] - Shell script

Hi All, I am doing this for svn patch making. I got the list of files to make the patch. I have the list in a file with path of all the files. To Do From Directory : /myproject/MainDir To Directory : /myproject/data List of files need to copy is in the file: /myproject/filesList.txt ... (4 Replies)
Discussion started by: linuxadmin
4 Replies

6. Shell Programming and Scripting

Copy files by automatically creating directories

I am in a situation where I have some hundreds of thousands of files in a directory (name of directory: big_directory). Now, working on this directory is extremely slow. I now plan to do this: Copy 1000 files in each of the directories by creating the directories automatically. All files have... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

7. OS X (Apple)

Moving Files Automatically

I'm looking to find/create a script so that when a download is complete, I can run the script in order for it to automatically move a file such as... 'example.avi' into my videos folder I'm a novice when it comes to scripting, any advice/help would be greatly appreciated! Thanks Andrew (10 Replies)
Discussion started by: abudis
10 Replies

8. Shell Programming and Scripting

Delete log files automatically.

Here is the script I want to run to deleted log files after a certain time: touch /usr/WebSphere/AppServer/profiles/AppSrv01/apps/RSA/logs find /usr/WebSphere/AppServer/profiles/AppSrv01/apps/RSA/logs -atime +120 - exec rm -rf {}\; Exerytime I run it, it throws me the error: find: paths must... (2 Replies)
Discussion started by: lennyz04
2 Replies

9. Shell Programming and Scripting

Convert a lot of files in subdirectories automatically

Hi, I have a huge structure of directories and subdirectories contsining some data. The lowest folders contain a file "image.png" which need to be converted to "folder.jpg". But how can I do that for all these files automatically? That's what I alredy have find /path -type f -name... (1 Reply)
Discussion started by: KarlKarpfen
1 Replies
shmx(8) 						      System Manager's Manual							   shmx(8)

NAME
shmx - shared memory exerciser SYNOPSIS
/usr/field/shmx [-h] [-ofile] [-ttime] [-msize] [-ssegment] [-v] OPTIONS
You can use the following options: Prints the help message for the shmx command. Uses the fork(2) system call instead of the vfork(2) call to spawn shmxb. Saves diagnostic output in file. Specifies the run time in minutes. The default is to run until the process is killed. Specifies the memory segment size in bytes to be tested by the processes. Must be greater than 0. The default is SHMMAX/SHMSEG. (SHMMAX and SHMSEG are system parameters set in the </sys/include/sys/param.h> file.) Specifies the number of memory segments. The default and maximum number is 3. DESCRIPTION
The shmx memory exerciser spawns the background process shmxb, and these two processes exercise the shared memory segments. They alternate writing and reading the other process' data in the segments. You can specify the number of memory segments to test and the size of the segment to be tested by shmx and shmxb processes. The shmx exer- ciser runs until the process is killed. A log file for you to examine and then remove is created in the current working directory. If there are errors in the logfile, check the syslog files where the driver and kernel error messages are saved. The shmx exerciser is automatically invoked when the memx exerciser is started. You can also invoke shmx manually. RESTRICTIONS
If you need to run a system exerciser over an NFS link or on a diskless system, there are some restrictions. For exercisers that need to write into a file system, such as fsx(8), the target file system must be writable by root. Also the directory from which the exercisers are executed must be writable by root because temporary files are written into the current directory. These latter restrictions are some- times difficult to overcome because often NFS file systems are mounted in a way that prevents root from writing into them. Some of the restrictions may be overcome by copying the exerciser to another directory and then executing it. EXAMPLES
The following example tests the default number of memory segments (3), each with the default segment size (SHMMAX/SHMSEG): % /usr/field/shmx & The following example runs two memory segments of size 100,000 bytes for 180 minutes: % /usr/field/shmx -t180 -m100000 -s2 & SEE ALSO
Commands: cmx(8), diskx(8), fsx(8), memx(8), tapex(8) shmx(8)
All times are GMT -4. The time now is 09:01 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy