Baanboard.com

Go Back   Baanboard.com > Blogs > gfasbender's blog

User login

Frontpage Sponsor

Main

Poll
For ERP LN feature pack upgrade, what method of install are you using?
Installation Wizard into existing VRC
37%
Installation Wizard into new VRC
39%
Manual into existing VRC
3%
Manual into new VRC
21%
Total votes: 38

Baanboard at LinkedIn


Reference Content

 
Remove zero-length files from a directory
By gfasbender at 4 Apr 2006 - 20:03

This program removes all zero-length files from the current UNIX directory.

 

/*--------------------------------------------------------------------
|* Title : rmzf.c - ReMove Zero-length Files
|* Description: : This program removes all zero-length files
| from the current UNIX direcory.
|* Author : Gordon Fasbender
|* Co-Author :
|* Date : 11/29/01
|******************************************************************************
|* Category : File I/O
|* Platform : UNIX
|*
|* License :
|* Copyright 2001 by Gordon Fasbender
|*
|* All Rights Reserved
|*
|* Permission to use, copy, modify, and distribute this software and its
|* documentation for any purpose and without fee is hereby granted,
|* provided that the above copyright notice appear in all copies and that
|* both that copyright notice and this permission notice appear in
|* supporting documentation.
|*
|* Gordon Fasbender and Baanboard.com DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
|* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|* AND FITNESS, IN NO EVENT SHALL Gordon Fasbender nor Baanboard.com BE LIABLE FOR ANY
|* SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE
|* OR PERFORMANCE OF THIS SOFTWARE.
--------------------------------------------------------------------*/
#define FALSE 0
#define TRUE !FALSE

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(int argc, char *argv[]);
void remove_trailing_spaces(char *str);

main(int argc, char *argv[])
{
char tbuf[200];
char tfile[200];
char tstr[200], *pstr;
FILE *rmzf_in;
int i;

system("ls -l > rmzf.tmp");

rmzf_in = fopen("rmzf.tmp","r");
while ((pstr = fgets(tstr, 199, rmzf_in)) != NULL)
{
if (atol(pstr+32) == 0 && strlen(pstr)>32)
{
sprintf(tfile,"%s", pstr+54);
remove_trailing_spaces(tfile);
printf("Deleted file <%s>\n", tfile);
sprintf(tbuf, "rm %s", tfile);
system(tbuf);
}
}
fclose(rmzf_in);
}

void remove_trailing_spaces(char *str)
{
while (str[strlen(str) - 1] == ' ' || str[strlen(str) - 1] == '\n')
str[strlen(str) - 1] = '\0';
}

 


0
No votes yet


All times are GMT +2. The time now is 20:51.


©2001-2017 - Baanboard.com - Baanforums.com