zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: Somehow smoking a pipe twice...?
Date: Sun, 30 Sep 2012 09:16:51 -0700	[thread overview]
Message-ID: <120930091651.ZM26459@torch.brasslantern.com> (raw)
In-Reply-To: <20120930122740.GA11056@solfire>

On Sep 30,  2:27pm, meino.cramer@gmx.de 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.


      parent reply	other threads:[~2012-09-30 16:17 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-30 12:27 meino.cramer
2012-09-30 12:52 ` Keith Bawden
2012-09-30 16:16 ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=120930091651.ZM26459@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).