Sponsored Content
Top Forums Shell Programming and Scripting Shell script to delete empty files from specific locations Post 302990699 by Khan28 on Tuesday 31st of January 2017 01:13:10 AM
Old 01-31-2017
Hi R.Singh,

Thanks for your reply. I am facing some problems:

I have tried to make the shell script as:

Directory path containing file:
Code:
 vim pathfile.txt
/d02/apps/output/UAT/CMFUP/reports


Code:
while IFS='' read -r  path;
do
name="$path"
echo "Finding Empty Files from location - $name"
find  $name -empty -print
done < "$1"

ran by executing

Code:
 ./CM_Del_Emp_files.sh pathfile.txt


Results in ERROR:
Code:
sysadm@xxxh016:[UAT:NRDP]:/d01/apps/ccb/UAT/scripts/cm> ./CM_Del_Emp_files.sh pathfile.txt
Finding Empty Files from location - /d02/apps/ccboutput/UAT/CMFUP/reports
find: `/d02/apps/output/UAT/CMFUP/reports\r': No such file or directory

 

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. Shell Programming and Scripting

copy similar files only both at different locations using script.

Hello, Here is the situation.............. # pwd /opt/123 # cat index.txt abc-monitor/homedir/public_html/index.php abc-monitor/homedir/public_html/test/index.php abc-monitor/homedir/public_html/test1/index.php # cp index.txt index.home # cat /root/x (1 Reply)
Discussion started by: fed.linuxgossip
1 Replies

3. Shell Programming and Scripting

How to delete a particular string from different locations ?

I want to delete a particular string ( ex : berkely@abc.com ) from different locations and in different files in each location. Please help me ! (4 Replies)
Discussion started by: nani_ynm
4 Replies

4. AIX

how to loop through non-empty files with shell script on AIX

I have av script that loops through some statistic files to create a report. We would like to only loop through non-empty files as these files create an empty report-line. I have figured out how to find the non-empty files, but not how to loop through only those files. Here is the code that finds... (4 Replies)
Discussion started by: Tessa
4 Replies

5. Shell Programming and Scripting

Need script to rename the files in different locations

Hi everybody, I need a script for below issue: I have totally 15 different locations like */COUNTRY/in. Only COUNTRy is the variable which changes for 15 countries. For each location(one per country), there will be four files like abc_def_ddmmyyyy.txt, where ddmmyyyy is the old date. ... (1 Reply)
Discussion started by: rjanardhan83
1 Replies

6. Shell Programming and Scripting

delete empty spaces at specific column

Hi All, If anybody could help me with my scenario here. I have a statement file. Example of some content: DATE DESC Debit Credit Total Rate 02-Jan-08 Lodgement 200.00 1200.00 2.51 14-Sep-07 Withdrawal 50.00 1000.00 ... (8 Replies)
Discussion started by: yonez
8 Replies

7. Shell Programming and Scripting

perl script to check if empty files are created and delete them and run a shell script

I have a local linux machine in which the files are dumped by a remote ubuntu server. If the process in remote server has any problem then empty files are created in local machine. Is there any way using perl script to check if the empty files are being created and delete them and then run a shell... (2 Replies)
Discussion started by: hussa1n
2 Replies

8. 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

9. Shell Programming and Scripting

Shell script to remove empty files

Hi All, Can anyone please write a shell script to remove the empty files using an if condition. please help me out , urgent thanks (6 Replies)
Discussion started by: muthi_murali
6 Replies

10. 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
file(1B)					     SunOS/BSD Compatibility Package Commands						  file(1B)

NAME
file - determine the type of a file by examining its contents SYNOPSIS
/usr/ucb/file [-f ffile] [-cL] [-m mfile] filename... DESCRIPTION
file performs a series of tests on each filename in an attempt to determine what it contains. If the contents of a file appear to be ASCII text, file examines the first 512 bytes and tries to guess its language. file uses the file /etc/magic to identify files that have some sort of magic number, that is, any file containing a numeric or string con- stant that indicates its type. OPTIONS
-c Check for format errors in the magic number file. For reasons of efficiency, this validation is not normally carried out. No file type-checking is done under -c. -f ffile Get a list of filenames to identify from ffile. -L If a file is a symbolic link, test the file the link references rather than the link itself. -m mfile Use mfile as the name of an alternate magic number file. EXAMPLES
Example 1: Using file on all the files in a specific user's directory. This example illustrates the use of file on all the files in a specific user's directory: example% pwd /usr/blort/misc example% /usr/ucb/file * code: mc68020 demand paged executable code.c: c program text counts: ascii text doc: roff,nroff, or eqn input text empty.file: empty libz: archive random library memos: directory project: symboliclink to /usr/project script: executable shell script titles: ascii text s5.stuff: cpio archive example% ENVIRONMENT VARIABLES
The environment variables LC_CTYPE, LANG, and LC_default control the character classification throughout file. On entry to file, these environment variables are checked in the following order: LC_CTYPE, LANG, and LC_default. When a valid value is found, remaining environ- ment variables for character classification are ignored. For example, a new setting for LANG does not override the current valid character classification rules of LC_CTYPE. When none of the values is valid, the shell character classification defaults to the POSIX.1 "C" locale. FILES
/etc/magic ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWscpu | +-----------------------------+-----------------------------+ SEE ALSO
magic(4), attributes(5) BUGS
file often makes mistakes. In particular, it often suggests that command files are C programs. file does not recognize Pascal or LISP. SunOS 5.10 14 Sep 1992 file(1B)
All times are GMT -4. The time now is 05:29 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy