Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Somehow smoking a pipe twice...?



On Sep 30,  2:27pm, meino.cramer@xxxxxx wrote:
}
} My first command runs inside my mailfolder and looks like this
} 
}     ls -l `grep -l kolkrabe *`
} 
} which give me a list of all files which contains the word "Kolkrabe"
} ("Kolkrabe" is german for "common raven". Latin "Corvus corax").
} 
} But additionally I want to know the contents of the line, which 
} matches the grep command added to the end of the line "ls -l"
} shows for each file.

Keith has it at least partly right here.  You need to let grep print
both the file name and the line contents.  At that point though, if
you want the "ls" output as well, you'll have to capture the grep
output and substitute in the "ls" output.

You can do this with something like:

    temp==(grep kolkrabe *) eval \
      'paste =(ls -l $(cut -d : -f 1 $temp)) =(cut -d : -f 2 $temp)'

But the only zsh-ish thing about that is the use of =(...) to manage
the temporary files for you.  "paste" also takes a -d option if you
want something other than a tab character between the ls output and
the grep output.



Messages sorted by: Reverse Date, Date, Thread, Author