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

423
Views
Cómo imprimir la ruta del archivo que provocó que fswatch hiciera algo

Uso fswatch para realizar algunas acciones cuando cambia un archivo. Yo uso el siguiente comando:

 fswatch -o -r '.' | while read MODFILE do echo 'Some file changed, so take some action' done

esto funciona bien, si cambio un par de archivos, veo lo siguiente en la terminal:

 Some file changed, so take some action Some file changed, so take some action Some file changed, so take some action etc.

Pero también me pregunto qué archivo realmente causó la acción. Así que revisé la página de manual de fswatch, que muestra lo siguiente:

 fswatch writes a record for each event it receives containing: - The timestamp when the event was received (optionally). - The path affected by the current event. - A space-separated list of event types (see EVENT TYPES ).

Pero como dije, no veo nada en mi terminal. ¿Alguien sabe cómo puedo mostrar " La ruta afectada por el evento actual". ?

¡Todos los consejos son bienvenidos!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Claro, usa esto:

 fswatch --batch-marker=EOF -xn . | while read file event; do echo $file $event if [ $file = "EOF" ]; then echo TRIGGER fi done

Si desea guardar los nombres de los archivos afectados en una lista, puede hacerlo así:

 #!/bin/bash fswatch --batch-marker=EOF -xn . | while read file event; do if [ $file = "EOF" ]; then echo TRIGGER echo Files: "${list[@]}" list=() else echo $file $event list+=($file) fi done
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!