grep getting confused by filenames with dashes
I’m having a problem where grep gets confused when the directory contains a file starting with dashes.
I’m having a problem where grep gets confused when the directory contains a file starting with dashes.
I have two files in these formats:
Context Line Control
I find the page numbers of a multiline pattern in a pdf file, by How shall I grep a multi-line pattern in a pdf file and in a text file? and How can I search a string in a pdf file, and find the physical page number of each page where the string appears?
I am trying to remove comments from a file which may be in any part of a line and span multiple lines. struct my_struct{ field1; field2; /** comment 1 */ field3; /* comment 2 */ } struct_name; I need to get struct my_struct{ field1; field2; field3; } struct_name; I tried using grep -o '[^/*]*[^*/]' to … Read more
I’ve been reading about sed and found that it was evolved from grep command.
I’ve seen someone use command: ps -ef | grep [h]ttpd and Output is: apache 25125 31006 0 21:54 ? 00:00:00 /usr/sbin/httpd apache 26869 31006 0 22:04 ? 00:00:00 /usr/sbin/httpd apache 27349 31006 0 22:07 ? 00:00:00 /usr/sbin/httpd apache 27696 31006 0 22:09 ? 00:00:00 /usr/sbin/httpd apache 28534 31006 0 22:14 ? 00:00:00 /usr/sbin/httpd root 31006 … Read more
I didn’t see any hits about this on google, so I’m asking you:
I want to monitor a file. So I have tailed a file using below command, to execute a script per line.
I am trying to use grep and cut to extract URLs from an HTML file. The links look like: