A
A
asergrisa2020-09-13 21:34:01
linux
asergrisa, 2020-09-13 21:34:01

What utility can delete files specified in the configuration file?

What utility can be used to delete files specified in the configuration file like this:

```
/usr/share/locale/*
!/usr/share/locale/en*
```

So that you can specify both the files to delete and the files that need to be saved.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry, 2020-09-13
@q2digger

cat + grep + if/not + rm
Or do you want to roll out a ready-made script? )

Z
zersh, 2020-09-13
@zersh

You can use perl script...

#!/usr/bin/perl

use strict;
use warnings;

my $CFG;
open ($CFG,"<config.cfg") or die "Cannot open config file: $!";

while (<$CFG>) {
    if (($_ =~ /^\!/)){
        next;
    } else {
    my $string = $_;
    chomp $string;
    unlink $string;
    }
}

if necessary, you can add checks for the presence of an empty string and a comment symbol in if
do not forget about backups *

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question