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! |
Replace | with &&
|
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... |
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:
|
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. |
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 |
That would only make you a file called cat in your current directory containing the output of the find command.
|
Aha. Better?
Code:
cat < 'find ./ -name bash.bashrc' |
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. |
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 :D (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 Code:
cat bash.bashrc |
I stand corrected. Your solution works.
Question is Why? What makes the difference from piping the stdout to cat and redirecting the stdin??? |
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? :D
|
All times are GMT -5. The time now is 04:47 AM. |