mktar: Use `wc` instead of `du` in summary message
[sunny256-utils.git] / lsreadable
blob00181d80c2a6a1da2e9713fdab6034bd695c5133
1 #!/usr/bin/env perl
3 #========================================================
4 # lsreadable
5 # File ID: 09014434-5d3f-11df-b91a-90e6ba3022ac
6 # Leser filnavn fra stdin eller en fil og skriver ut alle
7 # som er lesbar. Hvis -u spesifiseres, listes alle som
8 # IKKE er leselige. Hvis -w skrives, listes alle
9 # skrivelige/uskrivelige ting ut istedenfor.
10 #========================================================
12 use strict;
13 use warnings;
14 use Getopt::Std;
16 our ($opt_h, $opt_u, $opt_w) =
17 ( 0, 0, 0);
19 $| = 1;
21 getopts('huw') || die("Option error, -h for help\n");
23 if ($opt_h) {
24 print(<<END);
26 Syntax: $0 [options]
28 Reads filenames or directory names from stdin and prints name of every
29 file that is readable. This behaviour can be modified by the following
30 options:
32 -u Print file names of files which is NOT readable.
33 -w Check for write permissions instead of read permissions.
35 NOTE: Options may change in the future.
37 END
38 exit(0);
41 # Gjøres på amøbemåte for å få opp farta.
43 if ($opt_u) {
44 if ($opt_w) {
45 while (<>) {
46 chomp;
47 -w $_ || ! -l $_ && print("$_\n");
49 } else {
50 while (<>) {
51 chomp;
52 -r $_ || ! -l $_ && print("$_\n");
55 } else {
56 if ($opt_w) {
57 while (<>) {
58 chomp;
59 -w $_ && ! -l $_ && print("$_\n");
61 } else {
62 while (<>) {
63 chomp;
64 -r $_ && ! -l $_ && print("$_\n");