41 lines
1.2 KiB
Bash
Executable File
41 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
# -*- coding: utf-8 mode: sh -*- vim:sw=4:sts=4:et:ai:si:sta:fenc=utf-8
|
|
source "$(dirname "$0")/lib/ulib/auto" || exit 1
|
|
|
|
function display_help() {
|
|
uecho "$scriptname: frontend de grep pour lire des fichiers encodés en latin1
|
|
|
|
USAGE
|
|
$scriptname [options] files...
|
|
|
|
OPTIONS
|
|
options de grep qui sont reprises telles quelles"
|
|
}
|
|
|
|
grepopts=()
|
|
args=(
|
|
--help '$exit_with display_help'
|
|
-E,--extended-regexp '$grepopts+=(-E)'
|
|
-F,--fixed-strings '$grepopts+=(-F)'
|
|
-G,--basic-regexp '$grepopts+=(-G)'
|
|
-P,--perl-regexp '$grepopts+=(-P)'
|
|
-i,--ignore-case '$grepopts+=(-i)'
|
|
-v,--invert-match '$grepopts+=(-v)'
|
|
-L,--files-without-match '$grepopts+=(-L)'
|
|
-l,--files-with-matches '$grepopts+=(-l)'
|
|
-q,--quiet,--silent '$grepopts+=(-q)'
|
|
-s,--no-messages '$grepopts+=(-s)'
|
|
-H,--with-filename '$grepopts+=(-H)'
|
|
-h,--no-filename '$grepopts+=(-h)'
|
|
-a,--text '$grepopts+=(-a)'
|
|
-r,--recursive '$grepopts+=(-r)'
|
|
-R,--dereference-recursive '$grepopts+=(-R)'
|
|
)
|
|
parse_args "$@"; set -- "${args[@]}"
|
|
|
|
pattern="$1"
|
|
args=("${@:2}")
|
|
#XXX ajouter le support de -r, notamment si ${args[@]} contient un répertoire
|
|
|
|
iconv -f latin1 -t utf-8 "${args[@]}" | grep "${grepopts[@]}" "$pattern"
|