Sponsored Content
Top Forums Shell Programming and Scripting Shell script to delete empty files from specific locations Post 302990695 by Khan28 on Monday 30th of January 2017 10:26:18 PM
Old 01-30-2017
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 till end of the text file where path locations are defined.

Any template to meet this requirement will be greatly appreciated.

Contents of the file where multiple specified paths will be mentioned:

Code:
/b02/apps/appsoutput/UAT/INTERFACES
/b02/apps/appsoutput/UAT/FTP_XXSRDLS/stderr
/b02/apps/appsoutput/UAT/SORT_XXMRLP/stderr
/b02/apps/appsoutput/UAT/SORT_XXMRDP/stderr
/b02/apps/appsoutput/UAT/FTP_XXMRUP/stderr
/b02/apps/appsoutput/UAT/FTP_XXMRLP/stderr
/b02/apps/appsoutput/UAT/FTP_XXSRDL/stderr
/b02/apps/appsoutput/UAT/FTP_XXSRUPV/stderr
/b02/apps/appsoutput/UAT/SORT_XXMRDPQ/stderr
/b02/apps/appsoutput/UAT/SORT_XXMRDPQ/stderr
/b02/apps/appsoutput/UAT/SORT_XXMRLPQ/stderr
/b02/apps/appsoutput/UAT/SORT_XXMRLPQ/stderr
/b02/apps/appsoutput/UAT/XXMRDPNT/reports
/b02/apps/appsoutput/UAT/SORT_XXMRDPS/stderr


Last edited by Scrutinizer; 01-30-2017 at 11:38 PM.. Reason: Image removed
 

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
SHAR(1) 						    BSD General Commands Manual 						   SHAR(1)

NAME
shar -- create a shell archive of files SYNOPSIS
shar file ... DESCRIPTION
shar writes an sh(1) shell script to the standard output which will recreate the file hierarchy specified by the command line operands. Directories will be recreated and must be specified before the files they contain (the find(1) utility does this correctly). shar is normally used for distributing files by ftp(1) or mail(1). SEE ALSO
compress(1), mail(1), tar(1), uuencode(1) BUGS
shar makes no provisions for special types of files or files containing magic characters. EXAMPLES
To create a shell archive of the program ls(1) and mail it to Rick: cd ls shar `find . -print` | mail -s "ls source" rick To recreate the program directory: mkdir ls cd ls ... <delete header lines and examine mailed archive> ... sh archive HISTORY
The shar command appears in 4.4BSD. SECURITY CONSIDERATIONS
It is easy to insert trojan horses into shar files. It is strongly recommended that all shell archive files be examined before running them through sh(1). Archives produced using this implementation of shar may be easily examined with the command: egrep -v '^[X#]' shar.file 4.4BSD June 6, 1993 4.4BSD
All times are GMT -4. The time now is 07:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy