Re: Filtrar comodins/regex de les línies

Narcis Garcia <[email protected]>
Newsgroups gmane.linux.debian.user.catalan
Message-ID <[email protected]>
Aquesta proposta(2) té sentit, i de fet necessito incloure-ho en un 
programet ShellScript, però volia veure si podia evitar un bucle «for» 
utilitzant alguna comanda directa de grep, pcregrep o similar.

Gràcies.


El 17/1/24 a les 15:35, Xavier Drudis Ferran ha escrit:
> 
> 
> El primer cas que demanaves sembla fàcil
> 
> grep -f fitxer_regexps.txt fitxer_nums.txt
> 
> Pel segon no sé cap comanda directa, potser alguna cosa tipus
> 
> #!/bin/bash
> text=${1:-93123111}
> fitxer_regexps=${2:-fitxer_regexps.txt}
> 
> for r in $(< "$fitxer_regexps") ; do {
>     grep -qE "$r" - <<< "$text" && echo "$r" ;
> } ; done
> 
> 
> Però això podria ser més eficient si t'ho programes el perl o python o
> el que sigui...
> 

-- 

Narcis Garcia

__________
I'm using this dedicated address because personal addresses aren't 
masked enough at this mail public archive. Public archive administrator 
should remove and omit any @, dot and mailto combinations against 
automated addresses collectors.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.