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 SUSE
ftprestart
ftprestart(1M) System Administration Commands ftprestart(1M)
NAME
ftprestart - restart previously shutdown FTP Servers
SYNOPSIS
ftprestart [-V]
DESCRIPTION
Use the ftprestart command to restart an FTP Server previously shut down by means of ftpshut(1M). The ftprestart command reads the shutdown
capability from the ftpaccess(4) file to determine the path of the shutdown message files. It then reenables the FTP Server by removing any
shutdown message files in the anonymous and virtual FTP Server area, as well as the system wide shutdown message file.
OPTIONS
The ftprestart command supports the following options:
-V Display program copyright and version information, then terminate.
EXAMPLES
Example 1: Sample Output from ftprestart
The following example shows sample output from the ftprestart command:
example% ftprestart
ftprestart: /export/home/ftp/etc/ftpd/shutdown.msg removed.
ftprestart: /export/home/virtual1/etc/ftpd/shutdown.msg removed.
ftprestart: /etc/ftpd/shutdown.msg removed.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
>0 An error occurred.
FILES
/etc/ftpd/ftpaccess
/etc/ftpd/ftpservers
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWftpu |
+-----------------------------+-----------------------------+
|Interface Stability |External |
+-----------------------------+-----------------------------+
SEE ALSO
ftpshut(1M), in.ftpd(1M), ftpaccess(4), ftpservers(4), attributes(5)
SunOS 5.10 1 May 2003 ftprestart(1M)