LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 02-13-2016, 05:38 AM   #1
kikinovak
MLED Founder
 
Registered: Jun 2011
Location: Montpezat (South France)
Distribution: CentOS, OpenSUSE
Posts: 3,453

Rep: Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154
find and grep: strange behavior


Hi,

I just noticed something weird on a fresh installation of Slackware -current. Let's say I'm looking for all files containing "TERM" in /etc. Here's what I would do:

Code:
# grep -l "TERM" /etc/* 2> /dev/null | sort
/etc/DIR_COLORS
/etc/csh.login
/etc/login.defs
/etc/lynx.cfg
/etc/profile
/etc/termcap
/etc/termcap-BSD
/etc/termcap-Linux
/etc/zprofile
Now I'm doing things differently:

Code:
# find /etc -type f -maxdepth 1 | xargs grep -l "TERM" | sort
/etc/DIR_COLORS
/etc/csh.login
/etc/login.defs
/etc/lynx.cfg
/etc/profile
/etc/termcap
/etc/termcap-BSD
/etc/termcap-Linux
How comes /etc/zprofile doesn't appear when I use the second method?

Let's try this with a different character string. First method:

Code:
# grep -l "PS1" /etc/* 2> /dev/null | sort
/etc/profile
/etc/zprofile
Second method:

Code:
# find /etc -type f -maxdepth 1 | xargs grep -l "PS1" | sort
/etc/profile
Same thing. I'm puzzled. Any idea what's going on here?
 
Old 02-13-2016, 05:48 AM   #2
titopoquito
Senior Member
 
Registered: Jul 2004
Location: Lower Rhine region, Germany
Distribution: Slackware64 14.2 and current, SlackwareARM current
Posts: 1,646

Rep: Reputation: 146Reputation: 146
I think zprofile is a link, not a real file.
 
1 members found this post helpful.
Old 02-13-2016, 06:00 AM   #3
kikinovak
MLED Founder
 
Registered: Jun 2011
Location: Montpezat (South France)
Distribution: CentOS, OpenSUSE
Posts: 3,453

Original Poster
Rep: Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154Reputation: 2154
Quote:
Originally Posted by titopoquito View Post
I think zprofile is a link, not a real file.
Duh. Maybe I should go out a little bit.
 
Old 02-13-2016, 06:08 AM   #4
Paulo2
Member
 
Registered: Aug 2012
Distribution: Slackware64 15.0 (started with 13.37). Testing -current in a spare partition.
Posts: 928

Rep: Reputation: 515Reputation: 515Reputation: 515Reputation: 515Reputation: 515Reputation: 515
-L option (RTFindM )
 
Old 02-14-2016, 03:28 PM   #5
canadensis
Member
 
Registered: Sep 2013
Location: Sydney, Australia
Distribution: Slackware, xBSD, Gentoo, Calculate
Posts: 55

Rep: Reputation: 6
kikinovak: "Duh. Maybe I should go out a little bit."

LOL. But still interesting and possibly useful to note the different results you got with the two different searches.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] /bin/bash command not find, strange behavior of passwd , kworker is dying after start igadoter Linux From Scratch 4 01-27-2015 04:08 AM
[SOLVED] how to use cp find and grep together to copy a list of files using find with grep babhijit Linux - Newbie 10 07-03-2013 12:25 PM
[SOLVED] strange behavior of find tkmsr Linux - Newbie 16 01-07-2011 04:05 PM
strange behavior of find tkmsr Debian 8 05-12-2010 08:31 AM
strange behavior of find or grep alenD Programming 4 09-21-2007 06:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:59 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration