Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
04-04-2004, 11:59 PM
|
#1
|
Member
Registered: Mar 2004
Distribution: Debian 'Sarge'
Posts: 168
Rep:
|
Is this a valid command? find ./ -name bash.bashrc | cat
david:/etc# find ./ -name bash.bashrc
./bash.bashrc
However, when I do a
david:/etc# find ./ -name bash.bashrc | cat
./bash.bashrc
cat doesn't show the content of ./bash.bashrc
Is something wrong with my syntax?
Thanks!
|
|
|
04-05-2004, 12:00 AM
|
#2
|
Member
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394
Rep:
|
Replace | with &&
|
|
|
04-05-2004, 12:07 AM
|
#3
|
LQ Newbie
Registered: Jan 2003
Location: PA
Distribution: Gentoo
Posts: 27
Rep:
|
You are basically telling it to do the same thing both times
find ./ -name bash.bashrc
says find all files in the current directory named bash.bashrc
find ./ -name bash.bashrc | cat
says find all files inthe current directory named bash.bashrc then output to the cat command instead of standard out
you need to use the -exec switch with find to execute a command with the output
something like this:
find ./ -name bash.bashrc -exec cat {} \ ;
hope this helps...
|
|
|
04-05-2004, 06:04 AM
|
#4
|
Member
Registered: Mar 2004
Distribution: Debian 'Sarge'
Posts: 168
Original Poster
Rep:
|
I think I have a misconception here. Doesn't commandA | commandB means the output from commandA will be used as input for commandB ?
aka rpm -qa | grep grub ?
Thanks guys, these are very constructive replies
Quote:
Originally posted by phoenix
You are basically telling it to do the same thing both times
find ./ -name bash.bashrc
says find all files in the current directory named bash.bashrc
find ./ -name bash.bashrc | cat
says find all files inthe current directory named bash.bashrc then output to the cat command instead of standard out
you need to use the -exec switch with find to execute a command with the output
something like this:
find ./ -name bash.bashrc -exec cat {} \ ;
hope this helps...
|
|
|
|
04-05-2004, 09:11 AM
|
#5
|
Senior Member
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028
Rep:
|
The cat command concatenates the File to standard out (stdout), or in your case it concatenates the standard input (stdin) to standard out. That why it doesn't really read the file but just prints to stdout what it get in on stdin.
That's why you will have to use the -exec action.
|
|
|
04-05-2004, 09:30 AM
|
#6
|
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,639
Rep: 
|
If you want a laugh:
http://www.sektorn.mooo.com/era/unix/award.html
Else I don't understand. You are searching for bash.bashrc in your current directory (./), so it must be there to generate output anyhow?!?
Anyhow you can use ">" (I think) like
Code:
find ./ -name bash.bashrc > cat
|
|
|
04-05-2004, 09:34 AM
|
#7
|
Senior Member
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028
Rep:
|
That would only make you a file called cat in your current directory containing the output of the find command.
|
|
|
04-06-2004, 01:36 AM
|
#8
|
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,639
Rep: 
|
Aha. Better?
Code:
cat < 'find ./ -name bash.bashrc'

|
|
|
04-06-2004, 01:42 AM
|
#9
|
Senior Member
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028
Rep:
|
If that is going to have any posability to work you will have to use back quotes (`)
Back quotes will be substituted with the output of the command. That would be exactly like the first posted command and we are back at square one.
Go with phoenix answer it works. Belive us or try.
|
|
|
04-06-2004, 01:52 AM
|
#10
|
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,639
Rep: 
|
I think I used backticks on my keyboard (maybe the font shows them wrong). I don't dispute phoenix's way -- but mine has nine letters less  (if I discerned the blank spaces correctly).
What I still don't understand is why he wants to do it that way. I mean since he is in ./ he could just have typed and have done?!?
|
|
|
04-06-2004, 02:07 AM
|
#11
|
Senior Member
Registered: Dec 2000
Location: Gothenburg, SWEDEN
Distribution: OpenSUSE 10.3
Posts: 1,028
Rep:
|
I stand corrected. Your solution works.
Question is Why? What makes the difference from piping the stdout to cat and redirecting the stdin???
|
|
|
04-06-2004, 02:16 AM
|
#12
|
Senior Member
Registered: Apr 2003
Location: Germany
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,639
Rep: 
|
As I understand it it's just syntax  . I mean the output from one program has to be kept in memory and handed to the next program in both instances. Perhaps one of the moderators / gurus can enlighten us further. Hello? Anybody listening? 
|
|
|
All times are GMT -5. The time now is 10:02 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|