Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

321
Views
grep -f cuando el archivo de patrón también tiene algunas líneas vacías

¿Hay alguna opción del comando grep para suprimir el efecto de las líneas vacías en el archivo de patrones? Preferiría esta opción que verificar y filtrar siempre el archivo de patrón naciente.

Aquí hay un ejemplo (en pattern_file , hay una línea vacía):

 $ cat pattern_file APPLE PEAR $ cat file Nothing fruit $ grep -f pattern_file file Nothing fruit
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Para ignorar las líneas vacías en el archivo de patrón:

 grep -f <(grep . pattern_file) file
over 4 years ago · Santiago Trujillo Report

0

grep -v '^$'

Esto en realidad toma todas las líneas excepto las nuevas líneas. Puede canalizar el resultado a su grep de esta manera: grep -v '^$'| otherGrep

over 4 years ago · Santiago Trujillo Report

0

Acerca de la opción -f :

Un patrón nulo se puede especificar mediante una línea vacía en pattern_file .

Por lo tanto, es una función y debe eliminar las líneas vacías , por ejemplo, con sed :

 sed '/^$/d' | grep -f ...
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!