Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Moving files till the size is less than 200000. Post 19120 by rooh on Saturday 6th of April 2002 12:32:30 AM
Old 04-06-2002
Moving files till the size is less than 200000.

Hi,
I need your help.

Suppose I have a directory called /home/rooh
This directory contains files and directories.
For ex
drwxr-xr-x 3 rooha arboradm 96 Apr 6 03:24 batches
drwxr-xr-x 2 rooha arboradm 96 Apr 6 03:21 worker
-rw-rw-rw- 1 rooha arboradm 12661 Apr 4 05:46 RLO00220404144142ENG01
-rw-rw-rw- 1 rwata arboradm 16761 Apr 4 05:46 PD0022040414414200000AF-000
-rw-rw-rw- 1 rwata arboradm 13895 Apr 4 03:44 RLO00220404123602ENG01
-rw-rw-rw- 1 rwata arboradm 18586 Apr 4 03:44 SOR022040412360200000AF-000
-rw-rw-rw- 1 rwata arboradm 13749 Apr 4 03:44 SOR022040412360200000AF-001
-rw-rw-rw- 1 rwata arboradm 11974 Apr 4 03:44 RLO00220404123602ENG02

Now I want that I should list only the files and not directories and put them in a file.
So this is what I do:
cd /home/rooh
ls -al |grep ^->>/tmp/fileslist

So that looks fine. My /tmp/filelist contains only files and no directories.

Now what I want is that move the files from /home/rooh to /home/rooh/RIM/APRIL on the basis of size.
Means First I just want to move files till the size is less than 200000.

So I thought of doing something like this.
FILESIZE=0
for file in `cat /tmp/fileslist`
do
{
FILENAME=`cat $file |awk '{print $9}'`
#FILE=`cat $FILENAME |cut -f7 -d "/"`
SIZE=`cat $file |awk '{print $5}'`
if [ $FILESIZE -lt 200000 ]; then
{
mv $FILENAME /home/rooh/RIM/APRIL
[ $? = 0 ] && /bin/printf "$FILE\n " >> $LOGFILE
FILESIZE=`expr $FILESIZE + $SIZE`
}
else
/bin/printf "File size is $FILESIZE."
exit 1
fi
} done

But It gives me various error messages. Can you please suggest what i should do.
Or is there an alternate way of doing this.

Basically I just want to move files until the size is less than 200000.
Your suggestion will be highly appreciated.

Thanx a ton in advance for your valuable advice.

Rooh

Smilie
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

bash script working for small size files but not for big size files.

Hi, I have one file stat. Stat file contents are as follows: for example. H50768020040913,00260100,507680,13,0000000643,0000000643,00000,0000 H50769520040808,00260100,507695,13,0000000000,0000000000,00000,0000 H50770620040611,00260100,507706,13,0000000000,0000000000,00000,0000 Now i... (1 Reply)
Discussion started by: davidpreml
1 Replies

2. Shell Programming and Scripting

How to print lines till till a pattern is matched in loop

Dear All I have a file like this 112534554 446538656 444695656 225696966 226569744 228787874 113536566 443533535 222564552 115464656 225445345 225533234 I want to cut the file into different parts where the first two columns are '11' . The first two columns will be either... (3 Replies)
Discussion started by: anoopvraj
3 Replies

3. Shell Programming and Scripting

Want to zip the all files till nth depth

All, i need a script which can zip the all files which are in directories and its subdirectories for example: dir1 contains file1,file2,dir1a,dir1b now dir1a also contains fil11,fil12 ,dirab so script should look for files in dir or sub dir till files not found and... (2 Replies)
Discussion started by: vijays3
2 Replies

4. Shell Programming and Scripting

Program to tar files to packages less then 200000 bytes

Trying to write program to archive files from a file system. I got some problem with appropriate selection of files in regard to size. Algorithm basic : ----------------- 1. Remotely executes on machine ls cmd and its output redirects and sorts by size of a files : # cd... (0 Replies)
Discussion started by: presul
0 Replies

5. HP-UX

Make command performs badly and refuses to compile on 200000 files

I am trying to run make command on 200000 files in HP UX but it refuses to compile giving a message that " command line is too long .stop" I checked and found out that there is a limit imposed by the operating system on the command line .for Eg refer following link : The maximum length of... (6 Replies)
Discussion started by: madhur.tripathi
6 Replies

6. Shell Programming and Scripting

Pause shell script till folder doesn't change size anymore

Hi, I recently would like to write a shell script that 1. Runs in the background (can be done with "&", but i'd be happy for other solutions to keep programs running) 2. Does its stuff 3 THEN checks a specified folder for a size change over time (say, each 5 seconds. AND ONLY continues with... (9 Replies)
Discussion started by: pasc
9 Replies

7. Shell Programming and Scripting

Moving a file based on size

hello, I am creating a script that is going to scan the contents of a directory, and if it finds a certain DocumentName that is a certain size (The example, DocumentName and a size of 8777) If this file exists, it needs to be moved to a directory for later removal/processing..anyone have... (7 Replies)
Discussion started by: jeffs42885
7 Replies

8. UNIX for Dummies Questions & Answers

[SOLVED] How to set a default of 200000 as scrollback size in Putty ?

Putty release : 0.61 For saved sessions , you can configure Scrollback size just once using "Lines of Scrollback" in the 'Window' menu For a non-saved session (an ad-hoc session ) , If you want a higer scrollback size for a putty session , you have to set the "Lines of Scrollback" manually... (4 Replies)
Discussion started by: kraljic
4 Replies

9. Shell Programming and Scripting

Moving files based on size (string to integer)

I have a log file that I want to archive out as it reaches 100MB. I am using the following to get the file size into a variable but get the error "line 5: filesize=$(wc -c < logfile.log) if then echo "is greater than 100M" else echo "is less than 100M" fi I'm sure there's something... (2 Replies)
Discussion started by: Flakman
2 Replies

10. Shell Programming and Scripting

For loop till the files downloaded

Need assistance in writing a for loop script or any looping method. Below is the code where i can get all the files from the URL . There are about 80 files in the URL .Every day the files get updated . Script that i wanted is the loop must keep on running till it gets 80 files. It matches the count... (5 Replies)
Discussion started by: ajayram_arya
5 Replies
DBS-EDIT-PATCH(1)						Debian Build System						 DBS-EDIT-PATCH(1)

NAME
dbs-edit-patch - Edit a DBS patch SYNOPSIS
dbs-edit-patch [options] patch dbs-edit-patch -h|--help DESCRIPTION
dbs-edit-patch is script to generate or modify patches for Debian source-packages in DBS format. WARNING
dbs is deprecated, please switch to the `3.0 (quilt)' Debian source package format instead. See http://wiki.debian.org/Projects/Deb- Src3.0#FAQ for a short guide how to do it. OPTIONS
-h, --help Show summary of options. -t dir, --tmpdir=dir Directory for the temporary files, default is /tmp or if set $TMP. -s dir, --sourcedir=dir Top level directory of the debian-package source-tree, default is the present working directory. -P dir, --sourcepatchdir=dir Directory containing upstream patches. -T dir, --sourcetardir=dir Directory containing the upstream tarball. -p level, --strip=level Striplevel -p of patch (Option -p of diff(1)), accepted values are 0 and 1, default is 0. ENVIRONMENT VARIABLES
TMP Sets the directory for the temporary files, can be overridden with -t dir. debian/vars dbs-edit-patch will automatically use variables defined in the optional debian/vars file. When a file debian/vars.in exists and debian/vars either does not exist or is older than any of the following files: debian/vars.in, debian/changelog, debian/rules or debian/control, then dbs-edit-patch will try updating the vars file by running the following command make -f debian/rules -W debian/vars.in debian/vars EXAMPLES
Edit the 021_debian patch of Heimdal: ~/heimdal-0.3d> dbs-edit-patch -t/tmp 021_debian Extracting source heimdal-0.3d.tar.gz ... successful. Applying patch 001_replay ... successful. etc. Copying heimdal-0.3d to heimdal-0.3d-old ... successful. Applying patch 021_debian ... successful. Edit files under /tmp/021_debian/heimdal-0.3d as required, then put a short description into /tmp/021_debian/patch-description if desired, and finally execute /tmp/021_debian/dbs-update-patch to save the results. Technical note: dbs-edit-patch extracts all patches before 021_debian into /tmp/021_debian/heimdal-0.3d, copies the result to /tmp/021_debian/heimdal-0.3d-old, and applies the last patch 021_debian (if it exists). Also, it creates a shell script which will create the diff between the old and new directories: ~/heimdal-0.3d> ls -la /tmp/021_debian total 12 -rwxr-xr-x 1 bam users 112 Jan 31 13:31 dbs-update-patch* -rw-r--r-- 1 bam users 0 Jan 31 13:31 patch-description drwxr-xr-x 14 bam users 4096 Jan 31 13:31 heimdal-0.3d/ drwxr-xr-x 14 bam users 4096 Jan 31 13:31 heimdal-0.3d-old/ drwxr-xr-x 5 bam users 4096 Jan 31 13:31 .stampdir/ ~/heimdal-0.3d> cat /tmp/021_debian/dbs-update-patch #!/bin/sh -e cd "/tmp/021_debian" HOOK_DIR="/usr/src/heimdal/debian/dbs-hooks" test -d "$HOOK_DIR" && run-parts "$HOOK_DIR" --arg update-patch-prediff find -name "*.bak" -print0 | xargs -0 --no-run-if-empty rm find -name "*~" -print0 | xargs -0 --no-run-if-empty rm : > new_patch test ! -e patch-description || cp patch-description new_patch diff -ruN heimdal-0.3d-old heimdal-0.3d >> new_patch || test $? -eq 1 mv new_patch /usr/src/heimdal/debian/patches/021_debian test -d "$HOOK_DIR" && run-parts "$HOOK_DIR" --arg update-patch-postdiff SEE ALSO
diff(1), dbs(7), /usr/share/doc/dbs/ AUTHOR
DBS was written by Adam Heath, modified by Ben Collins, modified and packaged for Debian by Brian May. This manpage was generated by Andreas Metzler and modified by Robert Luberda. Debian February 15th, 2011 DBS-EDIT-PATCH(1)
All times are GMT -4. The time now is 12:48 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy