Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Somehow smoking a pipe twice...?
- X-seq: zsh-users 17301
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Re: Somehow smoking a pipe twice...?
- Date: Sun, 30 Sep 2012 09:16:51 -0700
- In-reply-to: <20120930122740.GA11056@solfire>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20120930122740.GA11056@solfire>
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