grep

Simple Terminal Command Question - Is there a command to pull a certain line out of an input?

Hey guys, I have a simple question. Is there a command that allows you to pull a certain line out of an input? Like if I wanted the 7th line from ifconfig. Is there a way to do this: ifconfig | [command] 7? Thanks! ...

for i in `ls |grep` question

This is the code i'm using to untar a file grep on the contents of the files within the tar and then delete the untared files. I dont have enough space to untar all files at once. the issue i'm having is with the for f in `ls | grep -v *.gz line this is supposed to find the files that have come out of the tar and can be identified by no...

Grep 'hg incoming' result for specific files and save result - if there is files im looking for

Hi! I want to create a script that will do something if hg incoming -v contains specific file. Say if hg incoming -v | grep models.py > 0 than do ./manage.py resetdb. Something like this. How can i set a flag (in bash script) based on hg incoming -v | grep manage.py result? ...

grep regex : extract pattern from all files in a directory

Lets say a directory has two files. Here are the contents File1.txt tagstart random string tagend tagstart random string tagend File2.txt tagstart random string tagend tagstart random string tagend I want to grep the directory and extract the lines that have the following pattern tagstart <any string> tagend I also want to pi...

How to add and remove items with JQuery from an array stored in a hidden field

I cant seem to do this in an elegant way, and I don't understand some of the behaviour I'm seeing. I have my array stored in html like so: <input type="hidden" id="myField" value="1,2,3,5,8,13"> To add a value I must do this, is this really the cleanest way to do this? $('#myField').val($('#myField').val() + ',' + 21); And to remo...

Help with regular expression and grep in Linux terminal.

I'm new to regular expressions and grep, but I've been trying to learn it to help me when using console tools. I have to use cvs, and when I update some files, I don't need to see files that were't updated or with *.pyc extension for example. So, I created a script that calls: cvs update -d | grep -v 'pyc$' | grep -v '^\?' First ques...

Data Cleanup, post conversion from ALLCAPS to Title Case

Converting a database of people and addresses from ALL CAPS to Title Case will create a number of improperly capitalized words/names, some examples follow: MacDonald, PhD, CPA, III Does anyone know of an existing script that will cleanup all the common problem words? Certainly, it will still leave some mistakes behind (less common name...

Any Mercurial extension to grep for newly checked in code (not having "console.log")?

Is there any Mercurial extension that can grep for "console.log" that might have been accidentally left over as debugging code? Right now this is what I am doing: 1) hg out ssh://.... the above is to see what is the first committed revision in my local repo, say, the smallest revision is 3456 2) hg diff -r 3455 | grep "^+" | grep ...

Grep for literal strings

I'm after a grep-type tool to search for purely literal strings. I'm looking for the occurrence of a line of a log file, as part of a line in a seperate log file. The search text can contain all sorts of regex special characters, e.g., []().*^$-\. Is there a Unix search utility which would not use regex, but just search for literal oc...

Finding a version number using grep

Basically i am creating an update checker for emesene on osx. I need to find out the version number from inside this file: http://emesene.svn.sourceforge.net/viewvc/emesene/trunk/emesene/Controller.py The version number is found at self.VERSION = 'version' in the file e.g. self.VERSION = '1.6.3' The version number then needs to be save...

grep command working in my testdir but not in the "real" directory why`?

I just thought I had found my solution because the command works in my test directory. grep -H -e 'author="[^"].*' *.xml | cut -d: -f1 | xargs -I '{}' mv {} mydir/. But using the command in the non-test-direcory the command did not work: This is the error message: grep: unknown option -- O Usage: grep [OPTION]... PATTERN [FILE]... ...

grep - put part of string into variable

Hi there. I'm using swfdump to be able to get the ID number of an audio file. Here is what I'm using: swfdump -D /Users/home/folder/file.swf | grep -i mp3 That is outputting: [00e] 28999 DEFINESOUND defines id 0006 (MP3 22Khz 16Bit mono) What I need is the id #..in this case it is 0006. i want that number in a variable. Anyone kno...

bash find chained to a grep which then prints

I have a series of index files for some data files which basically take the format index file : asdfg.log.1234.2345.index data file : asdfg.log The idea is to do a search of all the index files. If the value XXXX appears in an index file, go and grep its corresponding data file and print out the line in the data file where the value...

grep a file with a list of regular expressions

I have a large file of regular expressions, one per line. I would like to inverse grep another multi-line file against any regular expression that appears in the first file. Something like this: grep -v fileWithManyRegularExpressions fileThatMightMatchSomeRegularExpressions Is there an elegant method to do this aside from looping th...

how print all the attributes values of the title attributes in all my xml files

I wonder if anybode knows what command or bash-script-code I can use to print out all the values of the title attributes in all my xml files (in current directory). I'm using cygwin and have file names containing white spaces. ( I've been googling around and there are a lot of suggestions on downloading other utilities. If I can avo...

jQuery dynamically generate grep()

Hi, I'm using $.grep() to pull back a set of JSON results like so: myObject.appJSON = jQuery.grep(myObject.appJSON, function (a) { return a.category == "Entertainment"; }); and it works fine. But what I really want to do eventually is have several checkboxes so that that I can filter on several different things. I real...

grep from bottom to top of a file

hi, what is the option with grep or egrep through which we can search from bottom to up of a file normally they works in the top to bottom ...

Perl map/grep memory leak

I have been working on a perl project at work, and came across a strange memory leak. I have boiled down the source of my problem into a contrived example: #!/usr/bin/perl use strict; use warnings; # takes: an array reference # returns: 1 sub g { my ($a) = @_; return 1; } # takes: nothing # returns: the result of applying g ...

What are R's equivalents to Perl's map and grep?

I am interested in (functional) vector manipulation in R. Specifically, what are R's equivalents to Perl's map and grep? The following Perl script greps the even array elements and multiplies them by 2: @a1=(1..8); @a2 = map {$_ * 2} grep {$_ % 2 == 0} @a1; print join(" ", @a2) # 4 8 12 16 How can I do that in R? I got this far, us...

grep -v and -B|-A|-C not working together

I need to scan the output of iostat -En on a Solaris machine such that when a disk with errors is found, two lines about that disk are sent to the final output. This works fine so far using iostat -En | grep 'Errors: [1-9]' -A 1 but when I try to not include CD/DVD devices, I hit a wall. The contaxt flags (-A|B|C) don't seem to work w...