Sponsored Content
Top Forums Shell Programming and Scripting Please help list/find files greater 1G move to different directory Post 302895603 by dotran on Tuesday 1st of April 2014 12:25:27 PM
Old 04-01-2014
Please help list/find files greater 1G move to different directory

I have have 6 empty directory below. I would like write bash scipt if any files less "1000000000" bytes then move to "/export/home/mytmp/final" folder first and any files greater than "1000000000" bytes then move to final1, final2, final3, final4, final4, final5 and that depend see how many files, but I only want ONE file go into 1 directory. I run the command below with great than "1000000000" bytes and see 3 files then that 3 files should go 3 folders (final1, final2 and final3) only. If see more that 6 or 8 files greater than "1000000000" bytes then should go last folder "final5" . Is some kinda script loop through or command to do this? Please help with this task. Thanks
Code:
/export/home/mytmp/final  <= less "1000000000"
/export/home/mytmp/final1 <= greater "1000000000" but require only file move a
/export/home/mytmp/final2
/export/home/mytmp/final3
/export/home/mytmp/final4
/export/home/mytmp/final5
 
/export/home/mytmp/test1> ls -ltr test*.txt
-rwxrwxr-x   1 ca7prod  ftpusers 1073741824 Mar  4 11:14 test3.txt
-rwxrwxr-x   1 ca7prod  ftpusers 524288000 Mar  4 11:26 test4.txt
-rwxrwxr-x   1 ca7prod  ftpusers 629145600 Mar  4 11:28 test5.txt
-rwxrwxr-x   1 ca7prod  ftpusers 734003200 Mar  4 23:47 test7.txt
-rw-rw-r--   1 ca7prod  ftpusers      14 Mar 12 14:43 test.txt
-rw-------   1 ca7prod  ftpusers 52428800 Mar 31 15:24 test2.txt
-rw-rw-r--   1 ca7prod  ftpusers 104857600 Mar 31 15:27 test8.txt
-rw-rw-r--   1 ca7prod  ftpusers 1178599424 Mar 31 15:31 test9.txt
-rw-------   1 ca7prod  ftpusers 104857600 Mar 31 15:32 test10.txt
-rwxrwxr-x   1 ca7prod  ftpusers 104857600 Mar 31 15:37 test6.txt
-rw-rw-r--   1 ca7prod  ftpusers 157286400 Mar 31 15:38 test1.txt
-rw-rw-r--   1 ca7prod  ftpusers 1335885824 Mar 31 15:40 test11.txt
/export/home/mytmp/test1> ls -ltr test*.txt | awk '{if ($5 < 1000000000) print $9}' -exec mv {} /export/home/mytmp/final \;
test4.txt
test5.txt
test7.txt
test.txt
test2.txt
test8.txt
test10.txt
test6.txt
test1.txt
/export/home/mytmp/test1> ls -ltr test*.txt | awk '{if ($5 > 1000000000) print $9}' -exec mv {} /export/home/mytmp/xxx \;
test3.txt
test9.txt
test11.txt

Please with this script
/export/home/mytmp/test1> cat test.ksh
Code:
 
#!/bin/ksh
cd /export/home/mytmp/test1
###############################################################################
# Any files less than 1G move to final
###############################################################################
ls -ltr test*.txt | awk '{if ($5 < 1000000000) print $9}' -exec mv {} /export/home/mytmp/final \;
###############################################################################
# Any files greater than 1G move to final1, final2, final3, final4, final4, final5
###############################################################################
ls -ltr test*.txt | awk '{if ($5 > 1000000000) print $9}' |sed q | xxxxx bla bla
find /export/home/mytmp/test1 bla bla


Last edited by dotran; 04-01-2014 at 01:40 PM.. Reason: code tags please, not Quotes
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Important finding --- find files greater than 1 MB

as we can find file greater than 1 MB with find command as: find /dir -name '*' -size +1M find /dir/* -name '*' -size +1M but wats its doing is , its finding files only in current directory not in sub-directories. i want files from sub-directories too. Please help... Thanx in... (3 Replies)
Discussion started by: manoj_dahiya22
3 Replies

2. UNIX for Dummies Questions & Answers

Find files and display only directory list containing those files

I have a directory (and many sub dirs beneath) on AIX system, containing thousands of file. I'm looking to get a list of all directory containing "*.pdf" file. I know basic syntax of find command, but it gives me list of all pdf files, which numbers in thousands. All I need to know is, which... (4 Replies)
Discussion started by: r7p
4 Replies

3. Shell Programming and Scripting

find list of files from a list and copy to a directory

I will be very grateful if someone can help me with bash shell script that does the following: I have a list of filenames: A01_155716 A05_155780 A07_155812 A09_155844 A11_155876 that are kept in different sub directories within my current directory. I want to find these files and copy... (3 Replies)
Discussion started by: manishabh
3 Replies

4. Shell Programming and Scripting

Trying to find files equal to and greater than

Hi Guys and Gals, I'm having some difficulty putting this check into a shell script. I would like to search a particular directory for a number of files. The logic I have is pretty simple: Find file named *.txt that are newer than <this file> and count them If the number of files is equal to... (4 Replies)
Discussion started by: bbbngowc
4 Replies

5. UNIX for Dummies Questions & Answers

List of Files which are Greater then a specific date

A newbie question... I need to get a list of the Files and folders which are greater then a specific date. I want write the output to a Text file. What I know ls -lrt gives me list of all the files ordered by date. Also ls > fileName will write the results to a text file. Please help (6 Replies)
Discussion started by: rkaif
6 Replies

6. UNIX for Dummies Questions & Answers

look for file size greater than "0" of specific pattern and move those to another directory

Hi , i have some files of specific pattern ...i need to look for files which are having size greater than zero and move those files to another directory.. Ex... abc_0702, abc_0709, abc_782 abc_1234 ...etc need to find out which is having the size >0 and move those to target directory..... (7 Replies)
Discussion started by: dssyadav
7 Replies

7. Shell Programming and Scripting

Find files greater than a particular date in filename.

I need a unix command which will find all the files greater that a particular date in the file name. say for example I have files like(filenaming cov : filename.YYDDMMSSSS.txt) abc.201206015423.txt abc.201207013456.txt abc.201202011234.txt abc.201201024321.txt efg.201202011234.txt... (11 Replies)
Discussion started by: lijjumathew
11 Replies

8. Shell Programming and Scripting

Move files in a list to another directory

I have a number of files in a directory that can be grouped with something like "ls | grep SH2". I would like to move each file in this list to another directory. Thanks (4 Replies)
Discussion started by: kg6iia
4 Replies

9. UNIX for Dummies Questions & Answers

Find a list of files in directory, move to new, allow duplicates

Greetings. I know enough Unix to be dangerous (!) and know that there is a clever way to do the following and it will save me about a day of agony (this time) and I will use it forever after! (many days of agony saved in the future)! Basically I need to find any image files (JPGs, PSDs etc)... (5 Replies)
Discussion started by: Clyde Lovett
5 Replies

10. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies
MHPATH(1)                                                            [nmh-1.5]                                                           MHPATH(1)

NAME
mhpath - print full pathnames of nmh messages and folders SYNOPSIS
mhpath [+folder] [msgs] [-version] [-help] DESCRIPTION
mhpath expands and sorts the message list `msgs' and writes the full pathnames of the messages to the standard output separated by new- lines. If no `msgs' are specified, mhpath outputs the current mail folder's pathname instead. If the only argument is `+', your nmh "Path" is output; this can be useful in shell scripts. Contrasted with other nmh commands, a message argument to mhpath may often be intended for writing. Because of this: 1) the name "new" has been added to mhpath's list of reserved message names (the others are "first", "last", "prev", "next", "cur", and "all"). The new message is equivalent to the message after the last message in a folder (and equivalent to 1 in a folder without mes- sages). The "new" message may not be used as part of a message range. 2) Within a message list, the following designations may refer to messages that do not exist: a single numeric message name, the single message name "cur", and (obviously) the single message name "new". All other message designations must refer to at least one existing message, if the folder contains messages. 3) An empty folder is not in itself an error. A message number less than that of the smallest existing message in a folder is treated as if the message already exists. A message number greater than that of the highest existing message in a folder causes an "out of range" error message to be displayed. As part of a range designation that contains messages that do exist, message numbers less than the smallest, or greater than the highest, existing message in a folder are ignored. Examples: The current folder foo contains messages 3 5 6. Cur is 4. % mhpath /r/phyl/Mail/foo % mhpath all /r/phyl/Mail/foo/3 /r/phyl/Mail/foo/5 /r/phyl/Mail/foo/6 % mhpath 2001 mhpath: message 2001 out of range 1-6 % mhpath 1-2001 /r/phyl/Mail/foo/3 /r/phyl/Mail/foo/5 /r/phyl/Mail/foo/6 % mhpath new /r/phyl/Mail/foo/7 % mhpath last new /r/phyl/Mail/foo/6 /r/phyl/Mail/foo/7 % mhpath last-new mhpath: bad message list last-new % mhpath cur /r/phyl/Mail/foo/4 % mhpath 1-2 mhpath: no messages in range 1-2 % mhpath first:2 /r/phyl/Mail/foo/3 /r/phyl/Mail/foo/5 % mhpath 1 2 /r/phyl/Mail/foo/1 /r/phyl/Mail/foo/2 mhpath is also useful in back-quoted operations: % cd `mhpath +inbox` % echo `mhpath +` /r/phyl/Mail FILES
$HOME/.mh_profile The user profile PROFILE COMPONENTS
Path: To determine the user's nmh directory Current-Folder: To find the default current folder SEE ALSO
folder(1) DEFAULTS
`+folder' defaults to the current folder `msgs' defaults to none CONTEXT
None BUGS
Like all nmh commands, mhpath expands and sorts [msgs]. So don't expect mv `mhpath 501 500` to move 501 to 500. Quite the reverse. But mv `mhpath 501` `mhpath 500` will do the trick. Out of range message 0 is treated far more severely than large out of range message numbers. MH.6.8 11 June 2012 MHPATH(1)
All times are GMT -4. The time now is 11:25 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy