find

Find string and replace line in linux

时光总嘲笑我的痴心妄想 提交于 2019-12-22 11:27:58
问题 I'd like to do the following, but I can't seem to find an elegant way to do it. I have a text file that looks like this: ..more values stuff = 23 volume = -15 autostart = 12 more values.. Now the "volume" value may change, depending on the circumstance. I need a script that can find that line of text with "volume = xxx" then replace it with the line "volume = 0". What is an elegant solution to this? This line in the text is not guaranteed to be the first line, so I need a way to find it first

how to use echo with find in bash?

为君一笑 提交于 2019-12-22 10:09:04
问题 I have 10 files. I can list them with find . -type f and what I am trying to achieve is sending a message to all 10 files after finding them with find command. What I have tried, find . -type f -exec echo "This file found" >> {} \; May be logically I am right but its not working. Is there any way I can achieve with using find and echo only ? Thank you 回答1: The shell redirection, >> is being done at first, a file named {} is being created before even the find starts and the strings (the number

Unix 'find' + 'grep' syntax vs. awk

孤者浪人 提交于 2019-12-22 10:01:59
问题 I was using this line to find the phrase, 'B206' within files in the directory I was in and all of its sub directories. find . -exec grep -s "B206" '{}' \; -print It crashes when it tries to read certain files and actually changes the title bar in putty to a bunch of weird characters For example, it crashes all the time when it hits a jpg file that's in a sub directory. The title bar changes, and in the screen, there exists: ÐF»*rkNQeË+Z׳kU£~MÞçÄZ½ªéúýØâÑn¡[U+Þ4ªÒ9/ê£<ú¯4}[IÓ­îÃ¥K»G%ݳ¢

Searching c++ std vector of structs for struct with matching string

半世苍凉 提交于 2019-12-22 05:05:09
问题 I'm sure I'm making this harder than it needs to be. I have a vector... vector<Joints> mJointsVector; ...comprised of structs patterned after the following: struct Joints { string name; float origUpperLimit; float origLowerLimit; }; I'm trying to search mJointsVector with "std::find" to locate an individual joint by its string name - no luck so far, but the examples from the following have helped, at least conceptually: Vectors, structs and std::find Can anyone point me further in the right

find an item in a list of pointers

末鹿安然 提交于 2019-12-22 04:17:25
问题 I am trying to understand how to find an item in a list of pointers in C++, using std::find If I had for example: std::list<string> words; std::string word_to_be_found; I could just search like this: std::list<string>::iterator matching_iter = std::find(words,begin(), words.end(), word_to_be_found) but what if I have a lsit of pointers? std::list<string *> words; the above syntax will not work anymore. Can I do it some similar way? thanks! 回答1: You can pass a predicate to the std::find_if

Difference between Mac `find` and Linux `find` [closed]

微笑、不失礼 提交于 2019-12-22 03:53:12
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 6 years ago . I have inherited a script as part of a build process for an application, and when I run it on the build server (Ubuntu Precise) it runs fine, but when I run it on my mac I get "illegal option -- t". The command that has problems is simple, it's just a call to find : find -type f -not -path [...] On testing I

Unix find: list of files from stdin

不打扰是莪最后的温柔 提交于 2019-12-22 03:21:35
问题 I'm working in Linux & bash (or Cygwin & bash). I have a huge-- huge --directory structure, and I have to find a few needles in the haystack. Specifically, I'm looking for these files (20 or so): foo.c bar.h ... quux.txt I know that they are in a subdirectory somewhere under . . I know I can find any one of them with find . -name foo.c -print . This command takes a few minutes to execute. How can I print the names of these files with their full directory name? I don't want to execute 20

Find files modified within one hour in HP-UX

余生长醉 提交于 2019-12-22 00:25:21
问题 I'm searching through the manual page for find I can't see a way to run a command which will find all files modified within an hour. I can see only a way to do it for days. 回答1: Guess this should do find / -type f -mmin -60 This will be listing files starting from root and modified since the past 60 mins. 回答2: the best you can do in HP-UX using the find command is to look for everything that was modified in the last 24 hours. The HP-UX find command only checks modified time in 24-hour

Find contains class name in multiple classes

只愿长相守 提交于 2019-12-21 21:17:23
问题 I want to get the id in class like... <div class="main demo id_111 test"></div> <div class="main demo test id_222 test demo"></div> <div class="id_3 main demo test test demo"></div> Result must be 111 , 222 and 3 So I code like this var id = $(".main").attr("class"); var id = id.split("id_"); var id = id[1].split(" "); var id = id[0]; $("body").append(id); But someone know better coding than mine ? Playground : http://jsfiddle.net/UHyaD/ 回答1: You can use a regex : var id = $(".main").attr(

How can I list subdirectories recursively for HDFS?

对着背影说爱祢 提交于 2019-12-21 12:57:51
问题 I have a set of directories created in HDFS recursively. How can list all the directories ? For a normal unix file system I can do that using the below command find /path/ -type d -print But I want to get the similar thing for HDFS. 回答1: To list directory contents recursively hadoop dfs -lsr /dirname command can be used. To filter only directories , you can grep "drwx" (since owner has rwx permission on directories) in output of above command. Hence whole command will look like as below.