find

Unexpected operator error [duplicate]

早过忘川 提交于 2019-12-17 04:05:07
问题 This question already has an answer here : Bash scripting unexpected operator (1 answer) Closed 3 years ago . What is wrong in my code? #!/bin/sh LOOK_FOR="$1" for i in `find $2 -name "*jar"`; do echo "Looking in $i ..." #jar tvf $i | grep $LOOK_FOR > /dev/null jar tvf "$i" | grep "$LOOK_FOR" if [ $? == 0 ] ; then echo "==> Found \"$LOOK_FOR\" in $i" fi done #line 13 Output wk@wk-laptop:$ sh lookjar.sh org/apache/axis/message/addressing/EndpointReference /media/0C06E20B06E1F61C/uengine

Numpy: find first index of value fast

微笑、不失礼 提交于 2019-12-17 03:31:49
问题 How can I find the index of the first occurrence of a number in a Numpy array? Speed is important to me. I am not interested in the following answers because they scan the whole array and don't stop when they find the first occurrence: itemindex = numpy.where(array==item)[0][0] nonzero(array == item)[0][0] Note 1: none of the answers from that question seem relevant Is there a Numpy function to return the first index of something in an array? Note 2: using a C-compiled method is preferred to

Numpy: find first index of value fast

痞子三分冷 提交于 2019-12-17 03:31:10
问题 How can I find the index of the first occurrence of a number in a Numpy array? Speed is important to me. I am not interested in the following answers because they scan the whole array and don't stop when they find the first occurrence: itemindex = numpy.where(array==item)[0][0] nonzero(array == item)[0][0] Note 1: none of the answers from that question seem relevant Is there a Numpy function to return the first index of something in an array? Note 2: using a C-compiled method is preferred to

How can I store the “find” command results as an array in Bash

走远了吗. 提交于 2019-12-17 01:44:11
问题 I am trying to save the result from find as arrays. Here is my code: #!/bin/bash echo "input : " read input echo "searching file with this pattern '${input}' under present directory" array=`find . -name ${input}` len=${#array[*]} echo "found : ${len}" i=0 while [ $i -lt $len ] do echo ${array[$i]} let i++ done I get 2 .txt files under current directory. So I expect '2' as result of ${len} . However, it prints 1. The reason is that it takes all result of find as one elements. How can I fix

java regex match count

风格不统一 提交于 2019-12-17 00:14:19
问题 Let's say I have a file, and the file contains this: HelloxxxHelloxxxHello I compile a pattern to look for 'Hello' Pattern pattern = Pattern.compile("Hello"); Then I use an inputstream to read in the file and convert it into a String so that it can be regexed. Once the matcher finds a match in the file, it indicates this, but it doesn't tell me how many matches it found; simply that it found a match within the String. So, as the string is relatively short, and the buffer I'm using is 200

Python ElementTree module: How to ignore the namespace of XML files to locate matching element when using the method “find”, “findall”

﹥>﹥吖頭↗ 提交于 2019-12-16 22:10:31
问题 I want to use the method of "findall" to locate some elements of the source xml file in the ElementTree module. However, the source xml file (test.xml) has namespace. I truncate part of xml file as sample: <?xml version="1.0" encoding="iso-8859-1"?> <XML_HEADER xmlns="http://www.test.com"> <TYPE>Updates</TYPE> <DATE>9/26/2012 10:30:34 AM</DATE> <COPYRIGHT_NOTICE>All Rights Reserved.</COPYRIGHT_NOTICE> <LICENSE>newlicense.htm</LICENSE> <DEAL_LEVEL> <PAID_OFF>N</PAID_OFF> </DEAL_LEVEL> </XML

How to loop through file names returned by find?

强颜欢笑 提交于 2019-12-16 19:58:13
问题 x=$(find . -name "*.txt") echo $x if I run the above piece of code in Bash shell, what I get is a string containing several file names separated by blank, not a list. Of course, I can further separate them by blank to get a list, but I'm sure there is a better way to do it. So what is the best way to loop through the results of a find command? 回答1: TL;DR: If you're just here for the most correct answer, you probably want my personal preference, find . -name '*.txt' -exec process {} \; (see

Excel VBA Macro: Copying relative cell to another worksheet

时光总嘲笑我的痴心妄想 提交于 2019-12-14 04:23:00
问题 I am trying to fix missing entry by finding it and then copying the most left cell value relative to the found entry to the first empty bottom cell of another worksheet. With Worksheets("Paste Pivot").Range("A1:AZ1000") Dim source As Worksheet Dim destination As Worksheet Dim emptyRow As Long Set source = Sheets("Paste Pivot") Set destination = Sheets("User Status") Set c = .Find("MissingUserInfo", LookIn:=xlValues) If Not c Is Nothing Then firstAddress = c.Address Do 'Here would go the code

Find the rows of a matrix with conditions concerning the values of certain columns in matlab

一世执手 提交于 2019-12-14 03:27:30
问题 As the title says, I want to find all rows in a Matlab matrix that in certain columns the values in the row are equal with the values in the previous row, or in general, equal in some row in the matrix. For example I have a matrix 1 2 3 4 1 2 8 10 4 5 7 9 2 3 6 4 1 2 4 7 and I want to find the following rows: 1 2 3 4 1 2 3 10 1 2 4 7 How do I do something like that and how do I do it generally for all the possible pairs in columns 1 and 2, and have equal values in previous rows, that exist in

find command to rename files

淺唱寂寞╮ 提交于 2019-12-14 03:25:41
问题 I have created a list of files with names in uppercase alphabets and trying to rename them to files with the same names but in lowercase alphabets. So if i have 20 files with filenames like FILE1, FILE2, FILE3, etc. I want to rename them to file1, file2, file3, etc. respectively. I am executing the below command [root@host-1-1 files]# find . -name 'FILE*' -exec mv {} `echo {} | tr [:upper:] [:lower:]` \; But i am receiving below errors from mv command. Could someone please tell me what i am