ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
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.
You should use grep for manual searching in files. The simplest use is
Code:
grep "date_BBBCC" foo.txt
which will list all the lines in the file "foo.txt", where the pattern "date_BBBCC" appears. You can do custom searches using listing commands like tail or most. For example,
Code:
tail -n 100 foo.txt|grep -c "date_BBBCC"
will tell you how many times the pattern "date_BBBCC" is found in the last 100 lines of the file "foo.txt", without listing them (just counting them.)
To search in gzipped files, use something like
Code:
gzip -cd foo.gz|grep "date_BBBCC"
There are many more ways to use grep to do what exactly you want, too many to list them all here; man page for grep is the first step.
If, however, you just want to do such custom searches, and making a script for all that is not what you really need, I suggest installing Worker (must be available in most distros.) It is actually a very lightweight file manager (and very old-fashioned in looks) that can do all you are asking for very easily, and show results in a convenient way.
Hi All,
I am trying to write a script which would do following Job.
1.)Search for multiple patterns in a directory Eg patterns "abc" and "xyz" in directory "/dsd/audit". This pattern I want to search in files of certain pattern suppose the files are of pattern "date_BBBCC"
I want to search the pattern in both zip files as well as non zip files i.e in .Z files as well as regular files. Also I want to search for the pattern for only files of certain date ranges.
Please let me know how do I approch to write this script or how can this be done
This I am trying to do in AIX 5.3.
..and have been pointed to bash scripting tutorials. We will be very glad to HELP you, so post what YOU have written/tried first, and tell us where you're stuck. Otherwise, read the scripting tutorials, and break the tasks you're trying to accomplish down into commands you can type in. grep is obviously one, since you're searching for a pattern, as is find for finding files in a certain date range.
You posted questions like this more than a year ago...during that time, shouldn't you have learned something about scripting?
Tbone
Thanks for telling me the same thing what u have told me year long.Do u think ur answer had helped me then or now.But thanks again for pointing me to the same tutorials.
Tbone
Thanks for telling me the same thing what u have told me year long.Do u think ur answer had helped me then or now.But thanks again for pointing me to the same tutorials.
Spell out your words. And unless YOU actually start reading/following the tutorials, and writing your own scripts, you will NEVER learn how to do it for yourself. Coming back and asking for handouts over and over isn't a good thing.
If you're too lazy to learn, then PAY SOMEONE to write scripts for you. Don't ask people to do your work for free.
Tbone
Thanks for telling me the same thing what u have told me year long.Do u think ur answer had helped me then or now.But thanks again for pointing me to the same tutorials.
Sounds like what people call "trolling" nowadays. So, you admit you had the same questions... ONE year ago. And, let me guess, in the meantime you didn't bother reading the tutorials people pointed to you. A simple glance on them would be enough to start writing your own scripts. Even the few examples I posted earlier should be enough to get started as well. But apparently you just want (actually demand) someone to do the whole job to you, as if we are your servants. This, I can assure you, it won't happen.
We talk again if an when you have a script and you got stuck somewhere, when you first try and come back with specific questions... which, let me guess, it will never happen.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.