Sponsored Content
Top Forums Shell Programming and Scripting Need to move a file based on size Post 302399170 by Scott on Friday 26th of February 2010 02:19:47 PM
Old 02-26-2010
Code:
find /home/ww/w1/lo/reports -type f -depth 1 -size +0c -a -print | xargs -I{} mv {} /home/ww/w1/lo/newd

(remove -depth 1 to recursively copy everything into /home/ww/w1/lo/newd. If you want to maintain the structure under newd, then you're better off using a loop)

Last edited by Scott; 02-26-2010 at 03:44 PM.. Reason: Changed cp to mv... you did save move files!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Find, make and move file based on username

hi there, i'm new to UNIX( just 3month used), i found my new box contained alot of files and directories in /home/box/ i've tried to search script in tis forum and found many of them but, i don't know how to combine them to make a script, although using pipes. my tasks are: 1) to scan user... (5 Replies)
Discussion started by: Helmi
5 Replies

2. Shell Programming and Scripting

File Move Based on 1st Character of File Name

I need some help with a unix script to mv image files to subdirectories based on the 1st character of the filename. See example below... /images/main 1191.jpg 9999.jpg A101.jpg A102.jpg B201.jpg c333.jpg ... Z999.jpg I would like to move to the following: ... (11 Replies)
Discussion started by: srdconsulting
11 Replies

3. Shell Programming and Scripting

Search through subfolders and move them into separate folder on the base of file size

Hello guys I am sure that you will help me on this issue as you did earlier::) Scenario : I have a folder named "XYZ". It consist many sub-folders and subfolder contain severals files. there may be abc.dat in each subfolder. Now i want to seperate subfolders on follwing conditions- if abc.dat... (12 Replies)
Discussion started by: infiant
12 Replies

4. Shell Programming and Scripting

Move file based on filename

Hi All I need a script to manipulate files based on a filename: example filename: 66600_042706.pdf the script will create a directory 66000 only if this directory is not existing. If that directory is existing it will just move the file to 66000/666000_042706.pdf in addition, i want to... (4 Replies)
Discussion started by: aemestech
4 Replies

5. Shell Programming and Scripting

move contents from one file to another based on line number or content

I want a script that will move everything beyond a certain line number or beyond a certain content word into another file. For example, if file A has this: first line second line third line forth line fifth line sixth line I want to run a script that will move everything beyond the third... (4 Replies)
Discussion started by: robp2175
4 Replies

6. Fedora

Move file based time stamp

Hi all, I've already tired to try to solved this problem. Also search in Internet didn't find anything solution I have a directory like this : # pwd /opt/projects/juventini # ls -al | more total 3627460 drwxr-xr-x 2 app apps 12472320 Sep 24 14:59 . drwxr-xr-x 11 app apps 4096 Jun... (8 Replies)
Discussion started by: sunardo
8 Replies

7. Shell Programming and Scripting

Move input file based on condition

Hello, I have File1 in a directory A, a File2 in a directory B. If the File2 is not empty Then I have to move File1 from directory A to a directory archive Else no action. Is it possible to do this from one command line? Thank you in advance for your answers. Madi (2 Replies)
Discussion started by: AngelMady
2 Replies

8. Shell Programming and Scripting

Split file based on size

Hi Friends, Below is my requirement. I have a file with the below structure. 0001A1.... 0001B1.. .... 0001L1 0002A1 0002B1 ...... 0002L1 .. the first 4 characters are the sequence numbers for a record, A record will start with A1 and end with L1 with same sequence number. Now the... (2 Replies)
Discussion started by: diva_thilak
2 Replies

9. Shell Programming and Scripting

File Move based on date

how to move file based on date in linux (1 Reply)
Discussion started by: syedzoniac
1 Replies

10. Shell Programming and Scripting

Bash to move specific files to directory based on match to file

I am trying to mv each of the .vcf files in the variants folder to the folder in /home/cmccabe/f2 that the .vcf id is found in file. $2 in file will always have the id of a .vcf in the variants folder. The line in blue staring with R_2019 in file up to the -v5.6 will always be an exact match to a... (4 Replies)
Discussion started by: cmccabe
4 Replies
DUP3(3) 						   BSD Library Functions Manual 						   DUP3(3)

NAME
dup3 -- duplicate an existing file descriptor LIBRARY
Standard C Library (libc, -lc) SYNOPSIS
#include <fcntl.h> #include <unistd.h> int dup3(int oldd, int newd, int flags); DESCRIPTION
The dup3() function duplicates an existing object descriptor while allowing the value of the new descriptor to be specified. The close-on-exec flag on the new file descriptor is determined by the O_CLOEXEC bit in flags. If oldd != newd and flags == 0, the behavior is identical to dup2(oldd, newd). If oldd == newd, then dup3() fails, unlike dup2(2). RETURN VALUES
The value -1 is returned if an error occurs. The external variable errno indicates the cause of the error. ERRORS
The dup3() function fails if: [EBADF] The oldd argument is not a valid active descriptor or the newd argument is negative or exceeds the maximum allowable descriptor number [EINVAL] The oldd argument is equal to the newd argument. [EINVAL] The flags argument has bits set other than O_CLOEXEC. SEE ALSO
accept(2), close(2), dup2(2), fcntl(2), getdtablesize(2), open(2), pipe(2), socket(2), socketpair(2) STANDARDS
The dup3() function does not conform to any standard. HISTORY
The dup3() function appeared in FreeBSD 10.0. BSD
August 16, 2013 BSD
All times are GMT -4. The time now is 11:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy