Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > alt.os.linux.ubuntu > #197570 > unrolled thread

grep'ing a bunch of located files for a word

Started byfred flintstone <fred@server.invalid>
First post2017-11-07 08:53 -0800
Last post2017-11-08 05:37 -0500
Articles 5 — 5 participants

Back to article view | Back to alt.os.linux.ubuntu


Contents

  grep'ing a bunch of located files for a word fred flintstone <fred@server.invalid> - 2017-11-07 08:53 -0800
    Re: grep'ing a bunch of located files for a word Bit Twister <BitTwister@mouse-potato.com> - 2017-11-07 17:04 +0000
      Re: grep'ing a bunch of located files for a word Richard Kettlewell <invalid@invalid.invalid> - 2017-11-07 17:38 +0000
    Re: grep'ing a bunch of located files for a word Aragorn <thorongil@telenet.be> - 2017-11-07 18:36 +0100
      Re: grep'ing a bunch of located files for a word Chris Ahlstrom <OFeem1987@teleworm.us> - 2017-11-08 05:37 -0500

#197570 — grep'ing a bunch of located files for a word

Fromfred flintstone <fred@server.invalid>
Date2017-11-07 08:53 -0800
Subjectgrep'ing a bunch of located files for a word
Message-ID<f6e6nrF89adU1@mid.individual.net>
$ locate errno.h
/usr/include/errno.h
/usr/include/asm-generic/errno.h
/usr/include/linux/errno.h
/usr/include/x86_64-linux-gnu/asm/errno.h
/usr/include/x86_64-linux-gnu/bits/errno.h
/usr/include/x86_64-linux-gnu/sys/errno.h
...
/usr/src/linux-headers-4.8.0-56/arch/x86/include/uapi/asm/errno.h
/usr/src/linux-headers-4.8.0-56/include/linux/errno.h
/usr/src/linux-headers-4.8.0-56/include/uapi/asm-generic/errno.h
/usr/src/linux-headers-4.8.0-56/include/uapi/linux/errno.h
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.3 LTS
Release:	16.04
Codename:	xenial
$

How do I grep the located files for EEXIST ?
-- 
fred

[toc] | [next] | [standalone]


#197571

FromBit Twister <BitTwister@mouse-potato.com>
Date2017-11-07 17:04 +0000
Message-ID<slrnp03ptq.qrc.BitTwister@wb.home.test>
In reply to#197570
On Tue, 7 Nov 2017 08:53:13 -0800, fred flintstone wrote:
> $ locate errno.h
> /usr/include/errno.h
> /usr/include/asm-generic/errno.h
> /usr/include/linux/errno.h
> /usr/include/x86_64-linux-gnu/asm/errno.h
> /usr/include/x86_64-linux-gnu/bits/errno.h
> /usr/include/x86_64-linux-gnu/sys/errno.h
> ...
> /usr/src/linux-headers-4.8.0-56/arch/x86/include/uapi/asm/errno.h
> /usr/src/linux-headers-4.8.0-56/include/linux/errno.h
> /usr/src/linux-headers-4.8.0-56/include/uapi/asm-generic/errno.h
> /usr/src/linux-headers-4.8.0-56/include/uapi/linux/errno.h
> $ lsb_release -a
> No LSB modules are available.
> Distributor ID:	Ubuntu
> Description:	Ubuntu 16.04.3 LTS
> Release:	16.04
> Codename:	xenial
> $
>
> How do I grep the located files for EEXIST ?

while read -r fn ; do
  grep EEXIST $fn
done < <(locate errno.h)

[toc] | [prev] | [next] | [standalone]


#197573

FromRichard Kettlewell <invalid@invalid.invalid>
Date2017-11-07 17:38 +0000
Message-ID<87a7zyat0v.fsf@LkoBDZeT.terraraq.uk>
In reply to#197571
Bit Twister <BitTwister@mouse-potato.com> writes:
> On Tue, 7 Nov 2017 08:53:13 -0800, fred flintstone wrote:
>> $ locate errno.h
>> /usr/include/errno.h
>> /usr/include/asm-generic/errno.h
>> /usr/include/linux/errno.h
>> /usr/include/x86_64-linux-gnu/asm/errno.h
>> /usr/include/x86_64-linux-gnu/bits/errno.h
>> /usr/include/x86_64-linux-gnu/sys/errno.h
>> ...
>> /usr/src/linux-headers-4.8.0-56/arch/x86/include/uapi/asm/errno.h
>> /usr/src/linux-headers-4.8.0-56/include/linux/errno.h
>> /usr/src/linux-headers-4.8.0-56/include/uapi/asm-generic/errno.h
>> /usr/src/linux-headers-4.8.0-56/include/uapi/linux/errno.h
>> $ lsb_release -a
>> No LSB modules are available.
>> Distributor ID:	Ubuntu
>> Description:	Ubuntu 16.04.3 LTS
>> Release:	16.04
>> Codename:	xenial
>> $
>>
>> How do I grep the located files for EEXIST ?
>
> while read -r fn ; do
>   grep EEXIST $fn
> done < <(locate errno.h)

Rather slow and copes poorly with odd filenames.

  locate -0 errno.h | xargs -r0 grep EEXIST

...should do the job (untested).

-- 
https://www.greenend.org.uk/rjk/

[toc] | [prev] | [next] | [standalone]


#197572

FromAragorn <thorongil@telenet.be>
Date2017-11-07 18:36 +0100
Message-ID<otsqv9$7qj$1@dont-email.me>
In reply to#197570
On Tuesday 07 November 2017 17:53, fred flintstone conveyed the 
following to alt.os.linux.ubuntu...

> $ locate errno.h
> /usr/include/errno.h
> /usr/include/asm-generic/errno.h
> /usr/include/linux/errno.h
> /usr/include/x86_64-linux-gnu/asm/errno.h
> /usr/include/x86_64-linux-gnu/bits/errno.h
> /usr/include/x86_64-linux-gnu/sys/errno.h
> ...
> /usr/src/linux-headers-4.8.0-56/arch/x86/include/uapi/asm/errno.h
> /usr/src/linux-headers-4.8.0-56/include/linux/errno.h
> /usr/src/linux-headers-4.8.0-56/include/uapi/asm-generic/errno.h
> /usr/src/linux-headers-4.8.0-56/include/uapi/linux/errno.h
> $ lsb_release -a
> No LSB modules are available.
> Distributor ID:	Ubuntu
> Description:	Ubuntu 16.04.3 LTS
> Release:	16.04
> Codename:	xenial
> $
> 
> How do I grep the located files for EEXIST ?

  $ grep 'EEXIST' $(locate errno.h)

-- 
With respect,
= Aragorn =

[toc] | [prev] | [next] | [standalone]


#197574

FromChris Ahlstrom <OFeem1987@teleworm.us>
Date2017-11-08 05:37 -0500
Message-ID<otungo$5gd$4@dont-email.me>
In reply to#197572
Aragorn wrote this copyrighted missive and expects royalties:

> On Tuesday 07 November 2017 17:53, fred flintstone conveyed the 
> following to alt.os.linux.ubuntu...
>
>> $ locate errno.h
>> /usr/include/errno.h
>> /usr/include/asm-generic/errno.h
>> /usr/include/linux/errno.h
>> /usr/include/x86_64-linux-gnu/asm/errno.h
>> /usr/include/x86_64-linux-gnu/bits/errno.h
>> /usr/include/x86_64-linux-gnu/sys/errno.h
>> ...
>> /usr/src/linux-headers-4.8.0-56/arch/x86/include/uapi/asm/errno.h
>> /usr/src/linux-headers-4.8.0-56/include/linux/errno.h
>> /usr/src/linux-headers-4.8.0-56/include/uapi/asm-generic/errno.h
>> /usr/src/linux-headers-4.8.0-56/include/uapi/linux/errno.h
>> $ lsb_release -a
>> No LSB modules are available.
>> Distributor ID:	Ubuntu
>> Description:	Ubuntu 16.04.3 LTS
>> Release:	16.04
>> Codename:	xenial
>> $
>> 
>> How do I grep the located files for EEXIST ?
>
>   $ grep 'EEXIST' $(locate errno.h)

Don't even need the single-quotes :-)

I use "vi $(grep -rIl SYMBOLOFINTEREST)" all the time in my projects.

The xargs solution, I haven't had a need yet.

-- 
Alas, how love can trifle with itself!
		-- William Shakespeare, "The Two Gentlemen of Verona"

[toc] | [prev] | [standalone]


Back to top | Article view | alt.os.linux.ubuntu


csiph-web