utils/files.c
void file_remove_line(char *fname, char *str)
{
    FILE * fp;
    FILE * file;
    size_t len = 0;
    ssize_t read;
    char * line = NULL;

    /* Open templorary file */
    file = fopen("file.tmp", "a");
    if (file != NULL) 
    {
        /* Open exiting cache file */
        fp = fopen(fname, "r");
        if(fp != NULL)
        {
            /* Read from exiing cache file */
            while ((read = getline(&line, &len, fp)) != -1) 
            {
                /* Skip line if string exits on line */
                if(strstr(line, str) == NULL) 
                    fprintf(file, "%s", line);
            }

            /* Clean up memory */
            fclose(fp);
            if (line) free(line);
        }

        /* End up */
        fclose(file);
        remove(fname);
        rename("file.tmp", fname);
    }
}
/* 
 * remove_line - Remove exiting line from file. Function finds line 
 * and deletes it from file. First Argument file path and second 
 * argument str is keyword to find line which we want to delete. 
 */
Remove exiting line from file. Function finds line
and deletes it from file. First Argument file path and second
argument str is keyword to find line which we want to delete.
Remove exiting line from file . Function finds line and deletes it from file . First Argument file path and second argument str is keyword to find line which we want to delete .
void file_remove_line(char *fname, char *str)
{
    FILE * fp;
    FILE * file;
    size_t len = 0;
    ssize_t read;
    char * line = NULL;
    file = fopen("file.tmp", "a");
    if (file != NULL) 
    {
        fp = fopen(fname, "r");
        if(fp != NULL)
        {
            while ((read = getline(&line, &len, fp)) != -1) 
            {
                if(strstr(line, str) == NULL) 
                    fprintf(file, "%s", line);
            }
            fclose(fp);
            if (line) free(line);
        }
        fclose(file);
        remove(fname);
        rename("file.tmp", fname);
    }
}
void file_remove_line ( char * fname , char * str ) { FILE * fp ; FILE * file ; size_t len = 0 ; ssize_t read ; char * line = NULL ; file = fopen ( " " , " " ) ; if ( file != NULL ) { fp = fopen ( fname , " " ) ; if ( fp != NULL ) { while ( ( read = getline ( & line , & len , fp ) ) != -1 ) { if ( strstr ( line , str ) == NULL ) fprintf ( file , " " , line ) ; } fclose ( fp ) ; if ( line ) free ( line ) ; } fclose ( file ) ; remove ( fname ) ; rename ( " " , fname ) ; } }
remove_line - Remove exiting line from file.
remove_line - Remove exiting line from file .
/* Open templorary file */ /* Open exiting cache file */ /* Read from exiing cache file */ /* Skip line if string exits on line */ /* Clean up memory */ /* End up */