Linux - NewbieThis 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.
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.
Distribution: OpenSuse 10.2, Slackware 11, Solaris 10
Posts: 415
Rep:
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
Originally posted by irfanhab
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.
grep bash /etc/passwd
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:
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
Hmmm .. my ls doesn't display \ or * ... what are
your ls-options in env?
Distribution: Debian ("jessie", "squeeze"), Linux Mint (Serena), XUbuntu
Posts: 221
Rep:
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
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.