Try: sed -i '' '/^machine api.mydomain.com$/{N;N;d;}' ~/.netrc When this finds the line machine api.mydomain.com, it reads in two more lines and then deletes them all. Other lines pass through unchanged. For GNU sed, the argument to -i is optional. For OSX (BSD) sed, the argument is required but is allowed...
Second argument of substr is not an index of lat character to copy. It is length of target substring. l.push_back(line.substr(ex_pos, pos-ex_pos)); http://www.cplusplus.com/reference/string/string/substr/...
Here is the closet thing I could think of that does what you're wanting with the Find() method. If you change your 2D array to a List(Of Integer()) you can do the following: Imports System Imports System.Collections.Generic Imports System.Linq Public Module Module1 Public Sub Main() Dim A1() as Integer =...
Use std::map::upper_bound to find the value that is larger than x. Then decrement the iterator to find the smaller value and check which of these two is closer to x. Of course you have to check that you are only accessing valid iterators. In general you have to be careful...
You could make use of the $or operator to club these conditions together and execute them. The Boolean $or operator of the aggregation framework does an short circuit evaluation, i.e, if the preceding condition is satisfied, the rest of the conditions are not executed against the document. var condA =...
find Documents -name '*.blend[12]' -delete (-delete is a GNU find extension.) Other ways: find Documents '(' -name '*.blend1' -o -name '*.blend2' ')' -delete find Documents -name '*.blend*' -delete ...
Short Answer Use this array formula: =SUMPRODUCT(IF(IF(LEN(SUBSTITUTE(A:A,"ABC",""))<LEN(A:A),1,0)+IF(LEN(SUBSTITUTE(B:B,"ABC",""))<LEN(B:B),1,0)+IF(LEN(SUBSTITUTE(D:D,"ABC",""))<LEN(D:D),1,0)+IF(LEN(SUBSTITUTE(E:E,"ABC",""))<LEN(E:E),1,0)>0,1,0),C:C) Note: array formulas are entered with ctrl + shift + enter Explaination To test whether or not a cell contains ABC we can use the SUBSTITUTE forumla combined with a LEN to test the difference between the string lengths: LEN(SUBSTITUTE(A:A,"ABC",""))<LEN(A:A) We can then...
You can use awk to filter out your directory list: ls | awk '{if ($1 < 60000) print $1}' Lots of documentation and tutorials exist for awk....
I would suggest you to add the condition in your application layer, and keep your query that gets executed on the server very simple. If the match array has one or more elements, add a query field to your query condition, else execute an empty condition which would return you...
bash,find,exec,substitution,built-in
It took me a while to get the question. Basically you are asking if something like: echo "${test.png%.png}" could be used to get the word test. The answer is no. The string manipulation operators starting with ${ are a subset of the parameter substitution operators. They work only on variables,...
You can use find "$PWD", as in find "$PWD" -path '/dev' -prune -o -print, to search in the current directory by absolute path. Absolute path matches will then succeed.
excel,find,row,difference,subtract
If the numbers are always ordered from smallest to largest, you could simply do this: =MAX(C2:I2)-MIN(C2:I2) If not, things become a bit more difficult. Here's another solution that should work for non-ordered entries: First, add an empty column to the right of Totaal. Second, add seven columns with the following...
regex,replace,find,notepad++,edit
This one will work even if there are multiple <HTML>/<HEAD> tag pairs in the document: (?i)<\!--(?:(?!<HTML[^>]*>).)*?-->(?=(?:(?!<HTML[^>]*>).)*?<HEAD[^>]*>) Then ReplaceAll with empty string. Settings: ...
Give a look at http://sequelize.readthedocs.org/en/latest/docs/models-definition/#expansion-of-models That definitely gives you the chance to create a findByIdWithIncludes method on your Model...
javascript,jquery,find,toggle,show-hide
EDIT JSfiddle: click I changed a few thing: I removed your style from your HTML and put it in your CSS; You want to replace the divs so there is no need to hide any; Let me explain the JS: var divs = []; divs.push('<div class="content" id="empty">' + '<div class="box...
linux,bash,shell,find,escaping
Use an array, not a string. #!/bin/bash # ^-- must be /bin/bash, not /bin/sh, for this to work excludes=( ) for filename in *.txt; do excludes+=( -not -name "${filename%.txt}" ) done find . -type f -not -name '*.txt' "${excludes[@]}" -exec rm -f '{}' + To understand why this works, see...
javascript,jquery,html,find,show-hide
Just improving syntax or style of code you have written: $('[name=requestType]').on('change', function(){ if($(this).hasClass('triggerDiv')){ // show div + set default values $(this).not('select').prop('checked', true); $(this).not('input[type=checkbox], input[type=radio]').prop('selected', true); $('#requestDetails').show(); }else{ // hide div + reset fields $('#requestDetails').find('input[type=checkbox], input[type=radio], input, select').not(':button, :checkbox, :hidden, :radio, :reset, :submit').val('').prop('checked', false);...
regex,replace,sed,find,libreoffice
What you're trying to accomplish is unclear. Your text says "replace every", but your example shows replacing only the first space. To replace every: sed 'h;s/[^)]*//;s/ //g;x;s/).*//;G;s/\n//' What this does: h copy the line to sed's hold space s/[^)]*// replace not-a-) repeated with nothing. This deletes the first part of...
That's because ".tab:after" selector will return an empty set as jQuery and JavaScript in general can't select/manipulate CSS pseudo elements. You can use a class, toggle it and leave the manipulation to CSS. .tab.block:after { display: block; ... } $(".tab").toggleClass("block", $(".review").length > 0); http://jsfiddle.net/tzefrbvr/...
You can do something like #include <iostream> #include <string> int main() { std::string test = "we are searching for searching here"; std::string str = "searching"; std::string::size_type start = test.find(str); // find the first instance while(start != std::string::npos) // repeat for the rest { std::cout << "Found on pos: " <<...
You would tell grep that the patterns are in a file with the -f option, and use the "stdin filename" -: find ... | grep -r -f - *ext2 ...
string,actionscript-3,replace,find
You need to mask "(" and "*" in your pattern: var pattern:RegExp = /\(\*/gi; ...
if(std::find(inventory.begin(), inventory.end(), std::string("sword")) != inventory.end()) ... do not forget to include <algorithm>...
javascript,json,search,find,underscore.js
Here's a solution which creates an object where the keys are the uids: var catalogues = test.catalog; var products = _.flatten(_.pluck(catalogues, 'products')); var prices = _.flatten(_.pluck(products, 'prices')); var ids = _.reduce(catalogues.concat(products,prices), function(memo, value){ memo[value.uid] = value; return memo; }, {}); var itemWithUid2 = ids[2] var itemWithUid12 = ids[12] ...
I think you made a small mistake: When you backup on the 7th of may, you create a folder with name 070515. When you search a week later, you look for a folder with name 140515 modified more then 7 days ago. However, this folder has been created only today....
linux,bash,shell,command-line,find
If you can use the -regex option, avoiding subfolders with [^/]: ~$ find . -type f -regex ".*name1/[^/]*" -o -regex ".*name2/[^/]*" ./structure/of/dir/name2/file1.a ./structure/of/dir/name2/file3.c ./structure/of/dir/name2/subfolder ./structure/of/dir/name2/file2.b ./structure/of/dir/name1/file1.a ./structure/of/dir/name1/file3.c ./structure/of/dir/name1/file2.b ...
You can use .filter() too var array = [0,1,2,3,4,5] var removeItem = 3; array = array.filter(function(value) { return value != removeItem; }); Example...
Approach 1 To convert F from its current linear-index form into row indices, use mod: rows = cellfun(@(x) mod(x-1,size(A,1))+1, F, 'UniformOutput', false); You can combine this with your code into a single line. Note also that you can directly use B as an input to arrayfun, and you avoid one...
python,xml,parsing,find,branch
What you are doing will only work for immediate children of the root (i.e. "PublicFilings"). However, the tag you are after, "Registrant", is a grandchild, rather than an immediate child. In order to find a tag anywhere in the tree from root, use the following for each of your search...
Your basic problem comes down to the fact that the "selection" highlight won't be painted while the JTextArea doesn't have focus, I know, awesome. However, you could use a Highlighter instead, for example... if (source == find) { try { DefaultHighlighter.DefaultHighlightPainter highlighter = new DefaultHighlighter.DefaultHighlightPainter(UIManager.getColor("TextArea.selectionBackground")); MenuFrame.textarea.getHighlighter().addHighlight(n, n + search.length(), highlighter);...
windows,batch-file,cmd,find,errorlevel
find will filter the lines that match a requested condition. As some lines have passed the filter there is no reason to raise the errorlevel to signal that no matching lines have been found so it will be set to 0 errorlevel will be raised (set to 1) only when...
string,filter,find,underscore.js
var myArray = ["myString"]; if(myArray[0].IndexOf("my") != -1 || myArray.IndexOf("String") != -1 ) { ... } I didn't misunderstand the question, did I? Underscore.js wouldn't be required for this, either....
security,find,file-permissions
Something like find . -name '*.doc' -perm +0111 -exec chmod a-x ''{}'' ";" It will depend on exactly what you mean by "executable"....
node.js,mongoose,find,middleware
The issue ended up being the order of the items. Apparently you must define the model after setting up the find hooks. This is not required for the save and update hooks though. // define the schema for our recs model var recSchema = mongoose.Schema({ dis: String, // rec display...
If you cannot be sure if the two words stand together or the order might be unsure, you will have to search for both of them separately: findstr /i "\<James\>" sam1.txt | findstr /i "\<Henry\>" sam2.txt \<means "start of a word", \> means "end of a word, so you are...
You can use the -regex option: find -type f ! -regex '.*/media/.*' ...
Taking what you've written verbatim, assuming the first column in each file is the username: find . -name 'user*' -exec cat '{}' + | sort This concatenates all files found by find into a single stream, and pipes that stream to sort. By default, sort sorts starting at the beginning...
string,list,find,sml,substitute
You're making this way too complicated. This first function looks up a string in the first list: fun lookup ((a,b)::xs) v = if v = b then a else lookup xs v | lookup nil v = v; And this one just runs recursively on both elements in the second...
The semicolon (quoted or escaped) at the end of line is missing. It should be: find <file name> -type f -exec cat {} \; ...
To get the list of open files you can use lsof command. Get all the list of files from find command in a directory and remove them all. 1). Get the list of open files in a directory. lsof /folderToSearch |awk '{print $NF}'|sed -e '1 d' |sort |uniq >/tmp/lsof 2)....
It's not at all ideal, but you could do something like platform=`uname` if [$platform='Darwin']; then find app -type f -E posix-extended -regex '.+\.(handlebars|partial)' else find app -type f -regextype posix-extended -regex '.+\.(handlebars|partial)' fi Note that this will just assume linux if it's not OS X, and I think you need...
Don't replace the contents of body element using innerHTML replace, it can have side effects like can remove any registered event handlers etc.... instead target and replace the required var as = document.querySelectorAll('a[href*="?sid=XXXXXXXXXX"]'); for (var i = 0; i < as.length; i++) { var href = as[i].getAttribute('href'); as[i].setAttribute('href', href.replace(/\?sid=XXXXXXXXXX/g, ''));...
python,selenium,selenium-webdriver,find,element
First of all, using "layout-oriented" or "design-oriented" classes like btn-standard-lrg and btn-white is a bad practice. Instead, there is a convenient locator "by link text", use it: load_more = driver.find_element_by_link_text("LOAD MORE") Note how readable and simple it is. You may also need to wait until the "Load More" button would...
numList isn't a list of numbers, it's a list of strings. Try converting to integer before comparing to numFind. if int(num) == numFind: Alternatively, leave numFind as a string: numFind = input("Enter a number to look for: ") ... Although this may introduce some complications, e.g. if the user enters...
Hope the following solve your problem var img = $(".product-info").find('img:first'); ...
Simplest solution would be: var inputVal = $('input').val(); $('li:contains("'+inputVal+'")').css('background-color','#FF0000'); // or change any other CSS property to highlight ...
regex,algorithm,count,find,duplicates
One way is splitting your text based on your n then count the number of your elements that all is depending this counting you can use some data structures that use hash-table like dictionary in python that is much efficient for such tasks. The task is that you create a...
This becomes easier when you separate out the visiting of the tree elements from the minimum finding. It also makes it super easy to create a find_max function should you ever need it :-). Here's some code which should point you in the correct direction ... def visit(tree): for elem...
What I would suggest is to modify your structure to be able to make a query you want. My suggested structure is the following: { a: [ {b: 1, c: "a"}, {b: 2, c: "b"}, . . . ] } Then having your b value, you will be able to...
c#,excel,datagridview,find,search-engine
The idea: Add a private field to the class as an index to remember which row you last found. Reset this index if the search text is changed. (Optional) Iterate through all rows, beginning with the row following the last successful search. If no results were found last search, start...
vba,replace,find,wildcard,defined
Well, now I know a lot more about Find() in Word than I used to... This works for me in light testing, but will only the handle simple use case of single-word terms, where no term is a substring of another term. Sub Tester() Dim col As New Collection Dim...
In Python: import csv import os for root, dirs, files in os.walk(BASEDIR): for filename in files: basename, ext = os.path.splitext(filename) if ext.lower() != ".csv": continue path = os.path.join(root, filename) with open(path) as f: reader = csv.DictReader(f) for row in reader: if row['newColor'] == 'blue': print(row) # maybe? What's your output?...
regex,visual-studio,visual-studio-2013,replace,find
I'd suggest using Notepad++ > 'Find in Files' option to replace text in bulk. It works for files inside a specific directory or if needed, can traverse all sub-directories and replace them. See the below snapshot for settings needed ...
find's -regex matches against the whole path, not just the filename (I myself seem to forget this once for every time I use it). Thus, you can use: find . -regex '.*/[0-9]+\.html' (^ and $ aren't necessary since it always tests against the whole path.) Using find also has advantages...
html,regex,replace,find,notepad++
You could use the following: Find what: <url>[^<]+?<loc>[^<]+?/mailto/[^<]+?</loc>.+?</url> Search Mode: Regular Expression. Make sure you check . matches newline. This should remove the chunks you are after. You can then do the following: Edit -> Line Operations -> Remove Empty Lines (Containing Blank Characters) to clear your input....
>>> s = 'Something M6' >>> 'M' in s and s[s.rfind('M') + 1].isdigit() True >>> s = 'Something M1' >>> 'M' in s and s[s.rfind('M') + 1].isdigit() True >>> s = 'Something Mx' >>> 'M' in s and s[s.rfind('M') + 1].isdigit() False This works for single digits. It looks for...
&(?!#\d+;) This expression matches any ampersand character that is not followed by hash character with digits. Here is DEMO with more explanation....
I looked a little further on this and found the solution: To find all items, that belong to category.id 1 AND 2 (not OR) I just had to add a 'group' parameter to my find like this: $options['group'] = array('Item.id HAVING COUNT(DISTINCT Categorie.id) > 1'); The complete query (working): $kategories...
One way to remove the . prefix is to use sed. For example: find . ! -name . | sed -e 's|^\./||' The ! -name . removes the . entry from the list. The sed part removes the ./ from the beginning of each line. It should give you pretty...
Use the UNIX find command to search your entire disk starting at the root e.g. find / -name 'cupsctl' Shouldn't actually take all that long assuming an average sized SSD. A couple of seconds on my Mac $ sudo find / -name 'cupsctl' 2> /dev/null /usr/sbin/cupsctl or, as it's OS...
unity3d,find,parent-child,gameobject
Your question is a little confusing. This is what I understand from what you are asking. How to find a child object of parent object that changes its name during run time. You can do this with the FindChild function but there is another way of doing this. You can...
javascript,functional-programming,find,each
Your return is only returning from the inner (nested) function and your find function is indeed not returning anything, hence the undefined. Try this instead: var find = function(list, predicate) { // Functional style var ret; _.each(list, function(elem){ if (!ret && predicate(elem)) { return ret = elem; } }); return...
java,find,xslt-1.0,filenames,zsh
Here's a zsh approach, since it's tagged it as such. for f in **/*.foo(.); print -- java ... -o $f:r.bar $f Remove the print -- when you're satisfied that it looks good. The (.) says files only. The :r says remove the .foo extension. It's helpful to remember the path...
linux,ubuntu,permissions,find,chmod
Reference - [http://superuser.com/questions/91935/how-to-chmod-all-directories-except-files-recursively][1] 1.Most of the time consumed here would go in loading the chmod process for every entry. In order to avoid that use xargs- find /path/to/project -type d -print0 | xargs -0 chmod 755 find /path/to/project -type f -print0 | xargs -0 chmod 644 2.Fortunately, you can opt...
vba,excel-vba,loops,object,find
If the Cells.Find(What:="Run:" & i,... fails to find a match, the Select part of the statement will then cause the error. You should always store the result of a Find in a range variable and then test that for Nothing. Add this declaration to your code: Dim cellsFound As Range...
I actually found a good answer from another closely related question. I've only modified the command a little to adapt it to my needs: find . -type f -printf '%[email protected]\n' | sort -n | tail -1 %[email protected] returns the modification time as a unix timestamp, which is just what I...
In scalar context you can iterate over directory items using while(), and immediately break the loop when your condition is met, my $count = 0; while (defined(my $f = readdir $dir)) { if ($f =~ /\.wav$/ and ++$count >= 2) { print "there are at least two wav files\n"; last;...
c#,entity-framework,find,entity-framework-6
You are looking for a Contains query: var lServicosInformados = db.Servicos.Where(x => lCodigoServicos.Contains(x.PKId)); This assumes PKId is the name of your primary id column (you didn't specify the name)....
The problem is that you're working in the wrong direction. With your loop, if it finds the value in row 5 (x = 5), for example, it will add a row and shift the row where the value was found down (in this case from 5 to 6). When your...
algorithm,vba,function,find,fuzzy-search
Try this out, I think it will find the best match Function FuzzyFind2(lookup_value As String, tbl_array As Range) As String Dim i As Integer, str As String, Value As String Dim a As Integer, b As Integer, cell As Variant Dim Found As Boolean b = 0 For Each cell...
It looks like what you really want is to remove all empty directories, recursively. find . -type d -delete -delete processes the directories in child-first order, so that a/b is deleted before a. If a given directory is not empty, find will just display an error and continue....
Based on this question, but its solution does not preserve permissions, so I had to modify it. WARNING: since the recursive removal is a part of the solution, use it on your own risk Task: Recursively recode all project files (iso8859-8 -> utf-8) excluding '.git' and '.idea' dirs and preserving...
Try this: out = max(A(1,A(2,:) == 1)) Example: >> A A = 2 5 6 1 1 0 0 1 >> out out = 2 Explanation: (if you need) %// create a mask of which column you want mask = A(2,:) == 1 %// by checking all values of 2nd...
You can use Find What: (\S+)$ Replace with: $1 $1, Explanation: (\S+) is a capturing group that matches 1 or non-whitespace characters, and $ is the end of the line in Notepad++. Settings: ...
Try this: find . -mmin +35 -or -mmin -25 find supports several logical operators (-and, -or, -not). See the OPERATORS section of the man pages for more details. ==================== EDIT: In response to the question about processing the two matches differently, I do not know of a way to do...
OK discovered the answer. The \* wildcard is not a zero or more characters match. It is apparently a one or more characters match. The following does work $find . -name \*assembl\*.jar ./mllib-tests/target/mllib-perf-tests-assembly.jar ./spark-tests/target/spark-perf-tests-assembly.jar ...
regex,sed,find,pattern-matching
You can use the sed expression: sed 's/throw some::lengthy::exception();/throw CreateException(some::lengthy::exception());/g' And add it into a find command to check .h, .cpp and .hpp files (idea coming from List files with certain extensions with ls and grep): find . -iregex '.*\.\(h\|cpp\|hpp\)' All together: find . -iregex '.*\.\(h\|cpp\|hpp\)' -exec sed -i.bak 's/throw...
php,file,loops,while-loop,find
On pressing the submit button, I want the PHP code to check to see if a string exists within a webpage on another website. If I understood your question correctly, try this: $content = file_get_contents($url); if(str_replace($string, "", $content) != $content) echo "found"; EDIT: do { $content = file_get_contents($url); }...
Please note that the filesystem of a Docker container is not intended to be accessed by users from the host. It's quite complicated actually, since Docker uses a layered copy-on-write filesystem (like AUFS in your case, but that's distribution-specific; most Distros except Ubuntu use Devicemapper instead of AUFS, IIRC). What...
arrays,mongodb,find,aggregate,subdocument
What you are asking for here is a little different from a standard query. In fact you are asking for where the "name" and "lastname" is found in that combination in your array two times or more to identify that document. Standard query arguments do not match "how many times"...
Assuming, params[:type] is an array, you can search all users using where, and thereafter sort these results using order. You can find a similar example here. @users = User.where(:type.in => params[:type]).order(sort_by => sort_order).page(params[:page]).per(params[:per_page]) If you're looking for a translated mongoid query you can check out this link Your query might...
You can use this script: #!/bin/bash files=*.png for file in $files; do file="${file:0:-4}" [[ "$file" == *"."* ]] && newfile="${file//./_}" && mv "$file.png" "$newfile.png" done save it and then run it. Be sure to be in the directory where the files are in, when running it....
bash,error-handling,find,io-redirection
Because the 'permission denied' message is printed in stderr not stdout. 1 is stdout 2 is stderr & specifies that whatever following is a file descriptor not filename 2>&1 redirects stderr to stdout and enables the error message to be piped into the grep command. If excluding permission denied message...
The regex that works is \{\{\#lsth\:JointEntero_May_2015\|2015_May_([0-9]+)\}\} It is working because the { and } characters must be escaped in order to get matched as literal symbols. {} are usually used as quantifiers where we can set min and/or max characters corresponding to the preceding pattern to match. See the documentation:...
Here I am doing it using C: An array A[] of n numbers and another number x, determines whether or not there exist two elements in S whose sum is exactly x. METHOD 1 (Use Sorting) Algorithm: hasArrayTwoCandidates (A[], ar_size, sum) 1) Sort the array in non-decreasing order. 2) Initialize...
javascript,functional-programming,find,each
This has to do with how return works. Let's look at your code: var find = function(list, predicate) { // you pass list and an anonymous callback to `each` each(list, function (elem) { // if this condition is true if (predicate(elem)) { // return elem return elem; } }); }...
You need to quote or escape the * in your -name patterns, otherwise the shell tries to expand it and use the expanded form in its place in the command line. find /etc -type f -name '*.txt' -exec ls -lh {} \; 2>/dev/null | tee -a $ofile and the others...
c++,opengl,vector,find,duplicates
You can't compare floating point values simply using a simple x == y expression as if they were integers. You have to compare them using a "threshold", a "tolerance", e.g. something like: // Assuming x and y are doubles if (fabs(x - y) < threshold) { // x and y...
You can use the /C parameter: /C command Indicates the command to execute for each file. Command strings should be wrapped in double quotes. The default command is "cmd /c echo @file". The following variables can be used in the command string: @file - returns the name of the file....