Question about Grep
Hi all,
Is grep a tool that can only be used in conjunction with a pipe. I mean ls | grep "Xx" does produce results however grep "Xx" doesn't display anything instead, a new bash prompt doesnt appear, after giving this input. Can one use it standalone. Another questions: I go ls I see files like The\ Microsoft\ Computer\ Dictionary,\ Fifth\ Edition.chm* how can I make the output appear like The Microsoft Computer Dictionary, Fifth Edition.chm |
Re: Question about Grep
Quote:
In Unix/Linux everything is a file - STDIN is just a special case. You can either pipe it, or use it by its name :) Quote:
your ls-options in env? Cheers, Tink |
Well
grep "expression" directoy like grep "C++" /docs/programming does not work only grep expression filename works and the ls thingy It only happens when I access a vfat (FAT32) filesystem, it doesnt happen in native linux filesystems, but still it is annoying. anyways my LS options are LS_OPTIONS= --color=auto -F -b -T 0 |
Grep operates standalone
I love grep.
For years, hackers have kept phonebooks in text files (your friends names, addresses, birthdays etc.) grep -i irfanhab phonebook Would give me all the information I had about you in my phonebook. -i is ignore case (useful!). THere are other options to specify the length of "context" so that grep would print all the lines in phonebook that had your name as well as a couple above or below (that's the context). You asked about grep "Xx" You got a valid answer to your question, but not sure if it was clear, so I repeat, differently, in case it helps. grep "Xx" did not return to command line because it was searching for the string "Xx" in the file stdin (your terminal). It was waiting for you to close the file with a Ctrl-Z. So you'd want grep "Xx" filename to search for "Xx" in a particular file. If you want to seach for "Xx" in every file in a directory, then it's just grep "Xx" * ... That works fine. Can't help you on your ls question. |
Quote:
grep "C++" /docs/programming/* Quote:
Cheers, Tink |
Thanks everyone,
just one little question how do you change environment variables? |
By setting them to a new value...
e.g. export LS_OPTIONS=" --color=auto -b -T 0" If you like what that does you'll have to a) either look at your local bash-invocation scripts (~/.bashrc, ~/.bash_login or ~/.bash_profile) and change that there, or b) in /etc/profile Cheers, Tink |
All times are GMT -5. The time now is 10:16 AM. |