Search Results

Search found 2253 results on 91 pages for 'grep'.

Page 7/91 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • Obtain patterns in one file from another using ack or awk or better way than grep?

    - by Rock
    Is there a way to obtain patterns in one file (a list of patterns) from another file using ack as the -f option in grep? I see there is an -f option in ack but it's different with the -f in grep. Perhaps an example will give you a better idea. Suppose I have file1: file1: a c e And file2: file2: a 1 b 2 c 3 d 4 e 5 And I want to obtain all the patterns in file1 from file2 to give: a 1 c 3 e 5 Can ack do this? Otherwise, is there a better way to handle the job (such like awk or using hash) because I have millions of records in both files and really need an efficient way to complete? Thanks!

    Read the article

  • grep value inside a variable pointing to other variable

    - by Joice
    using : ksh *abc = 1 efg = 2 hgd = 3 not known to me * say if i have Value="abc efg hgd" abc efg hgd all contains some value which i dnt know. Now I want to grep the value contained inside abc. like for i in $Value do grep "echo $(($((echo $i | cut -d'|' -f2))))" done this grep should look for the value inside abc efg hgd grep 1 grep 2 grep 3

    Read the article

  • Searching Multiple Terms

    - by nevets1219
    I know that grep -E 'termA|termB' files allows me to search multiple files for termA OR termB. What I would like to do instead is search for termA AND termB. They do not have to be on the same line as long as the two terms exists within the same file. Essentially a "search within result" feature. I know I can pipe the results of one grep into another but that seems slow when going over many files. grep -l "termA" * | xargs grep -l "termB" | xargs grep -E -H -n --color "termA|termB" Hopefully the above isn't the only way to do this. It would be extra nice if this could work on Windows (have cygwin) and Linux. I don't mind installing a tool to perform this task.

    Read the article

  • Bash Script (Cygwin) to grep a logfile for multiple phrases and output a new file for each phrase.

    - by Chris
    Each logfile is titled based on the date it was created in the format YYYY-MM-DD.txt. I need to search each file for five different keywords and output five files prepended with the specific keyword and then the original logfile name. Example: Test-YYYY-MM-DD.txt grep -i -w 'keyword1' YYYY-MM-DD.txt Keyword1-YYYY-MM-DD.txt If it's also possible to email each new file to a different person, that would be helpful as well.

    Read the article

  • How to grep (or find) on cPanel?

    - by San
    How can I search for a specific string (function name or a variable name) in my files which are in various directories under cPanel file manager? I have been using a library directory and functions on that directory are used in various apps and pages. Now, I am in a situation to change something in the library file, for which I need to know the impact on files which use this library file functions. How to search / find / grep through the files hosted?

    Read the article

  • How does this Perl grep work to determine the union of several hashes?

    - by titaniumdecoy
    I don't understand the last line of this function from Programming Perl 3e. Here's how you might write a function that does a kind of set intersection by returning a list of keys occurring in all the hashes passed to it: @common = inter( \%foo, \%bar, \%joe ); sub inter { my %seen; for my $href (@_) { while (my $k = each %$href) { $seen{$k}++; } } return grep { $seen{$_} == @_ } keys %seen; } I understand that %seen is a hash which maps each key to the number of times it was encountered in any of the hashes provided to the function.

    Read the article

  • bash: expanding variables with spaces

    - by adam n
    i have a file called physics 1b.sh in bash, if i try x="physics 1b" grep "string" "$x".sh grep complains: grep: physics 1b: No such file or directory. However, when i do grep "string" physics\ 1b.sh it works fine. So i guess the problem is something to do with the variable not being expanded to include the backslash that grep needs to recognize the space. How do i get this to work? using bash 3.2, mac os 10.6.

    Read the article

  • What regular expression can I use to match an IP address?

    - by jennifer
    With the following grep syntax I want to match all IP address in a file (from a ksh script) grep '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' file The problem: It also matches words (IP) that have more then 4 octets: 1.1.1.1.1 or 192.1.1.1.160 How can I match a valid IP and only IP addresses with 4 octets? I can also use Perl – a one line syntax solution, if grep doesn't work.

    Read the article

  • Using watch with pipes

    - by Tom
    Hi! I'd like to run this command: watch -n 1 tail -n 200 log/site_dev.log | grep Doctrine But it does not run, because "I think" that the grep tries to run on the watch instead of the tail... Is there a way to do something like watch -n 1 (tail -n 200 log/site_dev.log | grep Doctrine) Thanks a lot!

    Read the article

  • Linux - Multiple service statuses with one command

    - by Jimbo
    I'm trying to retrieve a list of multiple service statuses in Unix. I'm using the service command: man page. The statuses all start with the transmission-daemon string, for example. I require the ability to list multiple services' statuses, with a single command. Here is what I'm currently trying (and failing) with: Here I'm trying to grab a list of statuses using grep. service $(ls /etc/init.d | grep "transmission-daemon") status Here I'm trying to list all statuses, and then grep for them. service --status-all | grep "transmission-daemon" This produces the following, which isn't much help: How can I effectively achieve what I require with a single command, so that I can then continue piping to awk for further customisation? Desired example output: transmission-daemon started transmission-daemon2 stopped transmission-daemon3 started

    Read the article

  • Search text in list of files. Double search. Search files within a files

    - by wormhit
    I'm trying to execute double search within files and return file names. I'm using find ./ -iname '*txt' | xargs grep "searchtext" -sl to find file names with 'searchtext' in them. Command is returning a list of files. How can I find "othersearchtext" in those already found files and show them in the same fashion? #### EDITED Answer: grep -l "othersearchtext" $(find ./ -iname '*txt' | xargs grep "searchtext" -sl)

    Read the article

  • I need to count the lines from matching config file entries, preferably with 'grep'.

    - by Chris
    I have a configuration file that has entries for various devices, with each entry separated by a blank line. I need to search the file for all instances of a given device type, and count the number of non-blank lines following the occurrence, stopping at the first blank. For example: Server=foo config line 1 config line 2 config line 3 Server=bar config line 1 config line 2 Server=foo config line 1 If I wanted to know how many total "config lines" were associated with server "foo", I should get four. Can you please help?

    Read the article

  • tail -f and then exit on matching string

    - by Patrick
    I am trying to configure a startup script which will startup tomcat, monitor the catalina.out for the string "Server startup", and then run another process. I have been trying various combinations of tail -f with grep and awk, but haven't got anything working yet. The main issue I am having seems to be with forcing the tail to die after grep or awk have matched the string. I have simplified to the following test case. test.sh is listed below: #!/bin/sh rm -f child.out ./child.sh > child.out & tail -f child.out | grep -q B child.sh is listed below: #!/bin/sh echo A sleep 20 echo B echo C sleep 40 echo D The behavior I am seeing is that grep exits after 20 seconds , however the tail will take a further 40 seconds to die. I understand why this is happening - tail will only notice that the pipe is gone when it writes to it which only happens when data gets appended to the file. This is compounded by the fact that tail is to be buffering the data and outputting the B and C characters as a single write (I confirmed this by strace). I have attempted to fix that with solutions I found elsewhere, such as using unbuffer command, but that didn't help. Anybody got any ideas for how to get this working how I expect it? Or ideas for waiting for successful Tomcat start (thinking about waiting for a TCP port to know it has started, but suspect that will become more complex that what I am trying to do now). I have managed to get it working with awk doing a "killall tail" on match, but I am not happy with that solution. Note I am trying to get this to work on RHEL4.

    Read the article

  • tail -f and then exit on matching string

    - by Patrick
    I am trying to configure a startup script which will startup tomcat, monitor the catalina.out for the string "Server startup", and then run another process. I have been trying various combinations of tail -f with grep and awk, but haven't got anything working yet. The main issue I am having seems to be with forcing the tail to die after grep or awk have matched the string. I have simplified to the following test case. test.sh is listed below: #!/bin/sh rm -f child.out ./child.sh > child.out & tail -f child.out | grep -q B child.sh is listed below: #!/bin/sh echo A sleep 20 echo B echo C sleep 40 echo D The behavior I am seeing is that grep exits after 20 seconds , however the tail will take a further 40 seconds to die. I understand why this is happening - tail will only notice that the pipe is gone when it writes to it which only happens when data gets appended to the file. This is compounded by the fact that tail is to be buffering the data and outputting the B and C characters as a single write (I confirmed this by strace). I have attempted to fix that with solutions I found elsewhere, such as using unbuffer command, but that didn't help. Anybody got any ideas for how to get this working how I expect it? Or ideas for waiting for successful Tomcat start (thinking about waiting for a TCP port to know it has started, but suspect that will become more complex that what I am trying to do now). I have managed to get it working with awk doing a "killall tail" on match, but I am not happy with that solution. Note I am trying to get this to work on RHEL4.

    Read the article

  • grep + add time out after some time if not find the relevant match

    - by yael
    Dear friends I use the following command syntax to search params in my script grep -qsRw -m1 "any_param" /dir/..../ Some times the search take avery long time The question is how to add time out to grep command For example after 20 seconds grep will break out If it not illegal to add time out to grep , how it will possible on other way? THX Yael

    Read the article

  • shell command to find a process id and attach to it?

    - by lallous
    Hello I want to attach to a running process using 'ddd', what I manually do is: # ps -ax | grep PROCESS_NAME Then I get a list and the pid, then I type: # ddd PROCESS_NAME THE_PID Is there is a way to type just one command directly? Remark: When I type ps -ax | grep PROCESS_NAME <- grep will match both the process and grep command line itself.

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >