Sponsored Content
Top Forums Shell Programming and Scripting Delete empty files from a directory entered in command prompt Post 302599634 by alister on Friday 17th of February 2012 04:54:37 PM
Old 02-17-2012
Code:
find "$dir" -mindepth 1 -prune -size 0c -exec rm {} \;

For greater efficiency, replace \; with +.

I don't think the task -- deleting empty files in a user-supplied directory without descending into any subdirectories -- can be reliably accomplished using just POSIX-standard find functionality (mindepth is an extension to POSIX).

In case someone cares to take a stab at it: http://pubs.opengroup.org/onlinepubs...ties/find.html.

Regards,
Alister

Last edited by alister; 02-17-2012 at 06:02 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

how to delete empty files in a shell script

I'm trying to figure out a way to delete empty files in a directory. I have a cron that runs and creates a flat file every 15 mins. However, most times at night the flat file will be empty. I'd like to run a script to delete empty files that end with *.dat Any suggestions? Rich (1 Reply)
Discussion started by: rpnuge
1 Replies

2. Solaris

How to delete Directory and inside files using Find command

I am using the following Command to delete Directory with contents. But this command is deleting inside files only not directories. is there any change need in my command? find -type f -mtime +3 -exec rm -r {} \; Thanks (3 Replies)
Discussion started by: bmkreddy
3 Replies

3. Shell Programming and Scripting

How to empty all files in a directory

Hi all, Can you tell me how to empty all files in a directory with a "find" command? It does not seem to work the way I try it: # ls -l *.dat -rw-r--r-- 1 root root 7 Jul 20 20:51 la2.dat -rw-r--r-- 1 root root 4 Jul 20 20:51 la.dat # find... (9 Replies)
Discussion started by: majormark
9 Replies

4. Shell Programming and Scripting

Prompt for 2 variables if nothing is entered end script

What I'm trying to do is write a bash file that prompts for the user's name and what the want to name the output file. If nothing is entered in either prompt the script must end and not create the output file. This is what I have so far: #!/bin/sh echo "What is your name?" read NAME if ... (4 Replies)
Discussion started by: kriminul1982
4 Replies

5. Shell Programming and Scripting

Script to delete empty files

I'm trying to write a shell script to files of zero length in a specified directory, but I keep getting errors. Would anybody be kind enough to look it over for issues? Thanks a bunch in advance. #!/bin/sh if then if then find $1 -type f -size 0 -print|xargs rm exit 0... (1 Reply)
Discussion started by: ScriptingIssues
1 Replies

6. Homework & Coursework Questions

Find and delete empty files and directories

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Need to make a script, to remove all empty files and folders from current category. It also should show the name... (2 Replies)
Discussion started by: Itixop
2 Replies

7. Shell Programming and Scripting

Script to delete folders and files from a prompt

Hi Everyone, I work for GE Money IVR as a DB analyst and the environment on which I work is Solaris 5.0 server and Oracle 11g. I got a project in which I have to clean up the folders and files which are not used in DB. I copied an existing script and edited it, dont know this is the... (5 Replies)
Discussion started by: habeeb506
5 Replies

8. Shell Programming and Scripting

To get the files in a directory for the given date (User entered date)

Need a ksh script to get the files that were created or modified in a directory on a particular date entered by the user. For example if a directory contains files as below : > ll total 41 -rw-rw-r-- 1 psn psn 199 Aug 23 07:06 psn_roll.sh -rw-rw-r-- 1 psn psn ... (10 Replies)
Discussion started by: ramprabhum
10 Replies

9. Shell Programming and Scripting

Command to delete half of files in directory.

Hello Friends, I have directory called /tmp. which stores the log files. Whenever it becomes full, i want to delete half of files from all log files. even after deleting the files, if space is more than 90% then it should delete rest of half files. While deleting files, older files... (7 Replies)
Discussion started by: Nakul_sh
7 Replies

10. Shell Programming and Scripting

Shell script to delete empty files from specific locations

Hi, I need help in regard to developing a shell script to delete empty files from multiple specific locations. The directory paths will be stored in a text file. So the requirement is to read the text file for one specific path and then remove empty files from that particular path. Looping through... (4 Replies)
Discussion started by: Khan28
4 Replies
uupick(8)						      System Manager's Manual							 uupick(8)

NAME
uupick - retrieve files transferred by uuto SYNOPSIS
uupick [-s system] [--system system] DESCRIPTION
The uupick program is used to conveniently retrieve files transferred by the uuto program. For each file transferred by uuto, uupick will display the source system, the file name, and whether the name refers to a regular file or a directory. It will then wait for the user to specify an action to take. One of the following commands must be entered: `q' Quit out of `uupick'. `RETURN' Skip the file. `m [directory]' Move the file or directory to the specified directory. If no directory is specified, the file is moved to the current directory. `a [directory]' Move all files from this system to the specified directory. If no directory is specified, the files are moved to the current directory. `p' List the file on standard output. `d' Delete the file. `! [command]' Execute `command' as a shell escape. OPTIONS
-s system, --system system Used to restrict `uupick' to only present files transferred from a particular system. Standard UUCP options: -x type, --debug type Turn on particular debugging types. The following types are recognized: abnormal, chat, handshake, uucp-proto, proto, port, config, spooldir, execute, incoming, outgoing. -I file, --config Set configuration file to use. -v, --version Report version information and exit. --help Print a help message and exit. SEE ALSO
uucp(1), uuto(1) AUTHOR
Ian Lance Taylor <ian@airs.com>. Text for this Manpage comes from Taylor UUCP, version 1.07 Info documentation. Taylor UUCP 1.07 uupick(8)
All times are GMT -4. The time now is 07:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy