Ubuntu :: Grep Or Sed And Put Into CSV?
Aug 12, 2011I'd to extract data from a log file and move those strings into a CSV.
Log File:
Code:
...
File = foo.bat
Date = 11/11/11
User = Foo Man
[Code]....
I'd to extract data from a log file and move those strings into a CSV.
Log File:
Code:
...
File = foo.bat
Date = 11/11/11
User = Foo Man
[Code]....
I need to kind of grep within grep. My input file would be something like:
[Code]....
and I need to find the first occurrence of hello before MY PATTERN (hello 9008 in this case), so the output should be:
[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 Relatedso i have a data file of a couple thousand lines. for example, my file will look like this (condensed of course):
Code:
something something 100 something 1 2 3
something something 101 something 4 5 6
[code]....
How would I use cut or grep to take this line :
Code:
Load......................... 198 Watt(22 %)
and make it into this information, in a text file :
Code:
198 Watts
If you don't mind, please explain the process, as I have been trying to figure this command out, and I must be missing something.
how to use grep with an expression that is constantly changing... basically this is what I am trying to do:
Code: watch "mpstat -P ALL | grep -e '`date +%r`'" which, should show me my CPU usage updated every couple seconds. The grep is being used to omit lines that aren't needed (all the useful lines start with the current time.) Problem is, it seems to execute the 'date +%r' command once.
I would like grep to execute the date command every time the watch command updates.
EDIT: I've found a workaround by putting the
Code: mpstat -P ALL | grep -e "`date +%r`" All in a shell file (that I called cpustat.sh), and then executing watch ./cpustat.sh
Would still like to know if there is an actual solution without having to create a seperate file (and preferably in one line). I have tried using a function to do the mpstat and grep part, but apparently watch doesn't play nice with functions
Is there any way to get information about whether something is currently played via the speakers? Is there an app that "scans" the VU-meter (e.g. pavumeter) in a terminal and prints out any information about the current "sound-volume" that goes out?I'd like to create a script that prevents my Ubuntu to suspend while something (e.g. music) is played... I know that e.g. Rhythmbox has a plugin for that, but I'd like to use SongBird...
View 5 Replies View RelatedI would like to take a file looking like...
uid=user1,ou=People,dc=company,dc=com
uid=user2,ou=People,dc=company,dc=com
uid=user3,ou=People,dc=company,dc=com
[Code]...
I 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?
At my work i have a legacy web system that tells the id of documents based on some given variables. this information can be used in another system to retrieve the needed file.
I am trying to automate this, and have managed to feed the variables and download the correct page using wget. The result is a result.php page with a lot of embedded info.
The information i am looking for is enclosed in single quotes on a line like this:
The information i want is the 1234 part.
I thought i could do like this from bash:
But I always get an empty string back... any idea what i am doing wrong?
I'm trying a recursive search -- only PHP files -- and yet grep is searching SQL files too.
Code:
sneakyimp@Ubuntu-64bit:/var/www/site$ grep -irl --include='*.php' 'car_images' *
2011_02_11_dump.sql
car_images_pending.sql
client/search_results.php
[Code]....
I'm attempting to find a particular word wherever it appears within a massive directory listing of teeny tiny text files -- and then copy all files containing this word into a "staging" directory.
Whenever I use the command below (on a test folder of smaller scale), it never carries the directory structure but attempts to copy all files within the "output" folder.
Code:
cp `grep -ir 'word' *` output
how to copy all these text files and have them retain some sort of directory structure?
Is there a way to use the grep command in conjunction with an editor such as nano or vi so that I can remove the commented out lines from a conf file and then proceed to edit it ? I can use grep -v "^#^" squid.conf (example ) which gives me a nicely tidy conf file but I can't edit it.Can this command be used with nano or ?
View 6 Replies View RelatedI need to find file from ls - l by using grep and certain regexp.
In particular I need greep to see certain file ending, like let's say .txt but only using regex.
So it should be something like
ls -l | grep '^.+.txt$'
But that doesn't seem to work for me.
I need to write a script that can search up to 3 parameters and find all files containing those words. then display them and the amount of hits it got.if the first parameter exists, then we can assume we are looking for the word supplied.if the second parameter exists, then we are looking for files with both keywords.if third parameter exists test the second parameter for the values ('and', 'or', '-v') and search accordingly. These are the only values accepted as the the second one when 3 parameters are present.
lastly, if there are zero or more than three parameters echo as an error and when 3 parameters have been entered we echo an error when the second parameter is not one of the following: 'and', 'or', '-v'.
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 RelatedSo theres this command
Code:
man -k mail
Which lists commands that contain the keyword "mail" in their description.I want the output of this command in less and the words highlighted by grep. Something like
Code:
man -k mail | grep mail | less
The command doesn't work, how do I fix it?
regex in grep? I need to match ANYTHING in the following with any character combination (something like * in findstr in C): grep "Delivery of nonspam" /var/log/mail.log | grep "to [URL]"
View 1 Replies View RelatedHere's my current regular expression(used in sed):sed 's///!Start.*//!End//g' in > outThe only problem being that the wildcard . does not work across multiple lines,
View 1 Replies View RelatedI have a problem with grep in my cron job:
A simple command like this doesn't work
Code:
Of corse I have tried with full path like this
Code:
Both of this scripts work fine when started from my shell. Unfortunately they don't work when executed from cron job, and I get an empty p.txt file.
Here is my crontab file:
Code:
Have any one of you faced this kind of problem before ?
how 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 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 RelatedI need to grep a dictionary file.Only the words that contain 2 or more z's and only 1 b needs to be listed.
View 1 Replies View RelatedI am trying to grep for A records in a bind zone file but I am failing.I am trying: grep "s+As+" db.domain.comBut there are no results.
View 12 Replies View RelatedToday, i checking my error log of Apache. I have look many IP brute scan URLo, i collect, export that to ip.txt and i need grep IP with connection >=8I don't know command to solve that. Example ip.txtQuote:
101 210.13.73.30
161 58.210.77.98
164 115.168.71.87
[code]....
I have a file which contains a line like this:SERVER=10.205.110.19 How can I cut out the IP and assign it to a variable?
View 4 Replies View RelatedHow can I use grep expressions so that i can find strings like the ones bellow:
New York, NY
Virginia, VA
Oregon, OR
As you can see each city starts with capital letter then it follows up with a comma, and then with the Abbreviation of the city. I used :
Code: grep -w '[A-Z].*[a-z][,][' '][A-Z][A-Z]' filename But i get no results.
I have on my desktop around five java files. I also created a java file in directory Viti, located in desktop.
Since all java files contain string "class", I practice my usage of grep with the following:
And this works fine. However, when I type the following:
I expect to be shown the file that's located in my Viti directory, too, but it won't show it.
I searched and I found a few threads on this but none answered my question really.I'm using:
Code:
curl www.foo.com | grep '<h2>.*.</h2>'
Basically I want to extract all instances of
Code:
<h2>Blah blah blah</h2>
from the page source, but it's not giving me that, it gives me <h2>.. followed by a loads of other stuff that I don't want. I haven't used wildcards with grep before so I don't really know whether I'm doing it right or not.
I am trying to monitor how long an ldap search takes and maybe notify or something that a search takes longer than say 10 seconds.
Code:
tail -n 1000 /var/log/ldap.log
for SRCH in $( cat monitorldap.log |grep 'SRCH'); do
echo search string is
echo $SRCH
[Code]....
ok, so to start off with it doesn't appear to get the whole line, just a piece "Aug". How can I get the whole line into a variable so I can then cut it up into the pieces I need?