General :: Search Date Period In Access Log Using Grep ?
Feb 19, 2010I have a three input day,month and year. Currently i am using the following script to take the data.
Any grep advanced technique to avoid for loop?
I have a three input day,month and year. Currently i am using the following script to take the data.
Any grep advanced technique to avoid for loop?
How can I use grep to search for line with either 'res' or 'rep'? i try "grep -e res|rep" or gre -e "rep|rep" but that does not work.
View 3 Replies View RelatedI am searching for Class declaration on a site with hundreds of PHP files, how can I do this in the current folder and subfolders using GREP?
I tested cding to the folder and then something like
grep -r 'class MyClass' *.php
I am using ascript for general users to back up usb drives to lto4 tapes.. I wish to ahve some error checking to check IF is there is a tape in the tape drive to check for the tape:
if i do a
sudo mt -f /dev/st0 status
i will get back a
mt: /dev/st0: rmtioctl failed: Input/output error
if there is no tape in the drive or
sudo mt -f /dev/st0 status
[code].....
I have done a bunch of searches on this but the terms seem to get tangled in the more popular search of "colouring the output of grep / awk". I am trying to find a way to grep/awk through the output of a command to find text of a specific colour. The command's output has a range of colours signifying too many different things to specify using text, with colour being the only form of grouping.
View 5 Replies View RelatedI need to search for the following pattern with GREP in a text file:
So I tried already:
But none of those works...I think probably because GREP doens't like the special character > in the middle of the serach pattern.
At the end I just need to now if GREP found the pattern in the file or not, so it should give me a 0 or a 1 back, once I check the value of the variable "?" after using the grep command.
I've been trying to identify all files on my cut-down version of Damn Small which contain the text string "User Agent:" in them. Because it's only 120Mb in its entirety, I'm quite happy to have grep search the whole system. I'm using this command, but it just generates errors as you can see:
[root@localhost ~]# grep -R 'User Agent:' /*
grep: /dev/dri/card0: Invalid argument
grep: /dev/fuse: Operation not permitted
[code]....
To search a string pattern in all files in a directory and subdirectories, I am using;
Code:
grep -R "myclass::my-func(" mydirectory/
Now I want grep, to search in only specific file types say *.cc. Please help me. I have read manual of grep, but could not deduce any hint.
Best Regards.
I need to search a text file for a string of numbers which are different lengths, and always are between number=" and " like:
number="1234567890"
number="22390"
I need to grab those numbers and pipe each one to a line in a file. I've already tried something with awk and that didn't seem to work.
I use the following command to find under /var some param in my script
grep -R "param" /var/* 2>/dev/null |grep -wq "param"
my problem is that: after grep find the param in file grep continue to search until all searches under /var/* will completed
How to perform stop immediately after grep match the param word
For example when I run the: grep -R "param" /var/* 2>/dev/null |grep -wq "param"
grep find the param after one second.
But grep continue to Search other same param on other files and its take almost 30 seconds
How to stop the grep immediately after param match?
I'd like to search the entire server by content. (text file) When I try grep -rl "text here", it freezes. How would you do it? And how long does it usually take?
View 4 Replies View RelatedHow can i use grep (or any other command) to check for lines that begin with N number.
E.g. I want to print out commands (from history), but only from the command number 50 until #200.
This one doesn't work:
Code:
history | grep "^[50-200]"
Should print out something like:
Code:
50 cd ~/Desktop
[Code].....
i want to search some key words in some pdf files grep myword ~/test.pdf that command can't work! grep command can't search pdf file??
View 1 Replies View Relatedhow to filter Date in terminal? I can filter a month from another month using grep but I cant grep multiple months. example, I want to show the data from 20/Jan/2011 to 10/Sep/2011. Grep can only show data of January and September. Is there any other unix commands I can use to achieve what I want?
View 9 Replies View RelatedI have a mail.log file, of which I want to redirect only the search strings of the sender from=<example.sender@exampledomain.com> and the size size=4537 to a file.
In every case the sender string starts as from=<> and the size string starts as size=
What would be the grep command to redirect only the two search strings to a .txt file?
I ran into a bit of trouble making a bash script. (Desktop is a directory, and I try to get it's modification date)
Code:
lamp:~# cmd='ls -l Desktop | grep -o "....-..-.. ..:.."'
lamp:~# $cmd
ls: cannot access |: No such file or directory
ls: cannot access grep: No such file or directory
[code]....
When I type in the command directly, without using an inbetween variable, it works fine.
I know you can use grep to find keywords in filenames, but is there a variation that can enable you to search the content of the files themselves?
View 9 Replies View Relatedhow to search for those files which contain word "AM_COLLECTION=22". I need to know all the files with this string. ( I know the grep command can do it but either
View 4 Replies View Relatedsomewhere lurking is a file containing the default print resolution, which is not being overwritten by printer settings or cups management. I've asked on the cup forum and nothing successful.
So here's the question:
How can I configure grep to search recursively through all files in a directory, or if need be starting from root to find the pattern "2880" I've looked in the man page for grep and I can't see how to do it, is grep the right tool to use for this ?
I want to pipe the output of a command into grep as the search TERM, rather than the text to be searched, like this for example
Code:
cat /var/log/auth.log | grep date "&b &d"
so that I only see the lines in auth.log for the current day...but obviously that line doesn't work.... is there a way to do this with grep, or even another command?
I know grep can search recursively (ie through all subdirectories to the bottom of the directory tree), but is it possible to ask grep to only search say, 3 levels down? That means the current directory, any directories in the current directory, and within any directories within those?
View 1 Replies View RelatedI'm looking for a c++ code that search for all files in computer between two input dates (example- 3.3.2011 and 11.4.2011)and copy all file in that range in new file .the user run the program and input date and path in dos system
View 8 Replies View RelatedI am using CRON to create a new, blank file, every minute, in a specific location on my web server. After web searching, and reading man pages, I get the impression that the following command is supposed to work:touch /home/mydomain/var/folder/attachments/`date +%H%M`.txtThis should give me a new file with a file name that is the current hour and minute.However, when executed, the CRON mailer reports:touch /home/mydomain/var/folder/attachments/`date +/bin/sh: -c: line 0: unexpected EOF while looking for matching /bin/sh: -c: line 1: syntax error: unexpected end of fileSo, it looks like shell is seeing the plus (+) sign as an EOFObviously, nothing get created.What would be the easiest, single line command to create an empty file, at a given location, with a time based file name
View 5 Replies View RelatedAnyone have a ksh solution to convert julian date to gregorian date?
View 6 Replies View RelatedI'm trying to recreate a simple script I wrote to parse out the access.log to get a rough idea of websites that users are going to on our corp network. The issue I'm having is I want to pull out any line from access.log that ends in .com/ .org/ .net/ or whatever to only see what the user entered into the address bar and drop pictures, js's and everything else and log only this. so what I do is :awk '{print $8} | grep -e '[cong]|[ore]|[mgtv][/]'$ and nothing happens.I know there is an easier way to do this with awk alone,
View 8 Replies View RelatedI am using cygwin in order to test a bash script that uses the ls -R command. When I use this, the access date of the subfolders are changed, and I need them to remain what they were before the command was run. I don't have access to a legitimate Linux system, so I'm not sure if this is the fault of cygwin or the ls command. The script is being used to find the last access date of all files underneath several subfolders and then return the latest date found in each subfolder as the last access date for that subfolder. For some reason, some of these folders have files in them that are newer than the folder's last access date, so the script is meant to give us a list of the true last access date for these folders.
View 5 Replies View RelatedBetween the dates 21-June-2007 to 12-December-2010 there are 1270 days. If the total cumulative time a hard drive has been active is 344 days (found this via Disk Utility in Ubuntu 10.10) since it was bought 1270 days ago. What is the average usage hours per day?
View 2 Replies View RelatedNow i am writting one bash script. in that my requirement is i need to create one directory and that the directory details to be stored in one file Ex. date/time and all in one file. after that i need to delete the folder automatically exactly after 3months. between these time period in 2month itself i need to send one mail to admin "regarding this still one month only more to delete the folder" . is it possible to do like that date calculation in script.
View 10 Replies View RelatedLucid 10.04, auto upgraded from 9.10, accessed through NoMachine NX from my MacBook Pro 10.6 system.
When I try to access the time settings through the System > Administration > Time and Date menu, all I get is the greyed-out display with the message Not authotized to make changes at the bottom.
With other administration functions, I am asked for sudo-style authorization with my password. That doesn't happen with Time and Date.
i want a service to be start at 8:00 and be ended in 14:00 automatically i already do this manualy by:
/etc/init.d/myservice.sh start
/etc/init.d/myservice.sh stop
i think it should be related to cron jobs.