04-01-2014
Thanks Mr Don C. It's really nice code and I still can't figure out why not move.
Quote:
#!/bin/ksh
cd /export/home/mytmp/test1
cld=0 # Current large directory
cutoff=${1:-1000000000} # Min file size to be considered "big"
lt1G_d=/export/home/mytmp/final # Directory to receive "small" files
ge1G_d_base="$lt1G_d" # Base directory name to receive "big" files
ge1G_d_cnt=5 # Number of directories for "big" files
printf "Prepare to move text files smaller than %s bytes to directory:\n" \
"$cutoff"
printf "\t%s\n" "$lt1G_d"
printf "and larger text files to directories:\n\t%s1 - %s%d\n" \
"$ge1G_d_base" "$ge1G_d_base" "$ge1G_d_cnt"
ls -ltr test*.txt | while read x x x x size x x x file
do if [ "$size" -ge "$cutoff" ]
then echo mv "$file" \
"$ge1G_d_base"$((cld = cld + 1 - (cld == ge1G_d_cnt)))
else echo mv "$file" "$lt1G_d"
fi
done
I run the code but somehow go to folder final, final1, final2....etc and didn't see the files move at all. I am missing something here. Could please help again? Thanks
Quote:
Prepare to move text files smaller than 1000000000 bytes to directory:
/export/home/mytmp/final
and larger text files to directories:
/export/home/mytmp/final1 - /export/home/mytmp/final5
mv test3.txt /export/home/mytmp/final1
mv test4.txt /export/home/mytmp/final
mv test5.txt /export/home/mytmp/final
mv test7.txt /export/home/mytmp/final
mv test.txt /export/home/mytmp/final
mv test2.txt /export/home/mytmp/final
mv test8.txt /export/home/mytmp/final
mv test9.txt /export/home/mytmp/final2
mv test10.txt /export/home/mytmp/final
mv test6.txt /export/home/mytmp/final
mv test1.txt /export/home/mytmp/final
mv test11.txt /export/home/mytmp/final3
---------- Post updated at 06:05 PM ---------- Previous update was at 06:00 PM ----------
Wow....sorry Mr Don C. It's really worked. I didn't remove echo and run the code work like a charm. Thanks very much....for your script expert.
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
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
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
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
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
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
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
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
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
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
LEARN ABOUT XFREE86
dh_movefiles
DH_MOVEFILES(1) Debhelper DH_MOVEFILES(1)
NAME
dh_movefiles - move files out of debian/tmp into subpackages
SYNOPSIS
dh_movefiles [debhelperoptions] [--sourcedir=dir] [-Xitem] [file...]
DESCRIPTION
dh_movefiles is a debhelper program that is responsible for moving files out of debian/tmp or some other directory and into other package
build directories. This may be useful if your package has a Makefile that installs everything into debian/tmp, and you need to break that
up into subpackages.
Note: dh_install is a much better program, and you are recommended to use it instead of dh_movefiles.
FILES
debian/package.files
Lists the files to be moved into a package, separated by whitespace. The filenames listed should be relative to debian/tmp/. You can
also list directory names, and the whole directory will be moved.
OPTIONS
--sourcedir=dir
Instead of moving files out of debian/tmp (the default), this option makes it move files out of some other directory. Since the entire
contents of the sourcedir is moved, specifying something like --sourcedir=/ is very unsafe, so to prevent mistakes, the sourcedir must
be a relative filename; it cannot begin with a `/'.
-Xitem, --exclude=item
Exclude files that contain item anywhere in their filename from being installed.
file ...
Lists files to move. The filenames listed should be relative to debian/tmp/. You can also list directory names, and the whole directory
will be moved. It is an error to list files here unless you use -p, -i, or -a to tell dh_movefiles which subpackage to put them in.
NOTES
Note that files are always moved out of debian/tmp by default (even if you have instructed debhelper to use a compatibility level higher
than one, which does not otherwise use debian/tmp for anything at all). The idea behind this is that the package that is being built can be
told to install into debian/tmp, and then files can be moved by dh_movefiles from that directory. Any files or directories that remain are
ignored, and get deleted by dh_clean later.
SEE ALSO
debhelper(7)
This program is a part of debhelper.
AUTHOR
Joey Hess <joeyh@debian.org>
11.1.6ubuntu2 2018-05-10 DH_MOVEFILES(1)