In BBEdit, how can I search for a pattern and then copy all the lines found with that pattern? - bbedit

In BBEdit (11.6.9), using find with grep checked on I'm looking for lines in a large file containing this pattern:
registeredTd="11/\d\d/2017
It stands for a registered date of November, 2017 in my file.
If I "find all" I get correctly see 69 occurrences of the pattern in the file i the results window.
But how, then, can I copy those found lines?
I can copy the results of the results window itself, but that copy (1) contains extra junk at the beginning and most importantly (2) does not contain the complete line. The lines in the result window are truncated.
Is there a way of copying all the complete lines containing the pattern?
Thanks,
doug

For what it's worth, the answer to this was to use the Text > Process Lines Containing... menu. There you can enter the same registeredTd="11/\d\d/2017 search parameter, and there is a checkbox option to copy the lines with the search results. It works perfectly.

Related

parse text file to find lines which contain a date after 05/05/2011

I could like to be able to list the line no.s in a file which contain a date, in the format dd,mm,yy, which is greater than 05/05/11
the file in question is prolog source code - the dates form part of a comment indicating when the modification after the comment was made
I'm using emacs, so thought an emacs solution would be the obvious way forward but willing to think more laterally if need be
a typical line of interest would be:
4.00 21/10/12 Modified to incorporate proportional match tolerances
I would like to report the file and line no. e.g.
filename line no.
my_source_1.pl 37
or alternatively, just being able to step through the file using Regexp I-search highlighting each dd/mm/yy that is greater than 05/05/2011 would be very useful

diff ignore certain pattern in the file

I want to make diff between two files which contains lines beginning with "line_$NR". I want to make diff between the files making abstraction of the presence of "lines_$NR" but when the differences are printed I want lines_$NR to be displayed.
It is possible to do that?
Thanks.
I believe in this case, you have to preprocess your iput files to remove /^line_[0-9]*/, diff the resulting files, then recombine the diff output with the removed words according to line numbers in diff output.
Python's difflib should be very handy here, or same from perl. If you want to stick to shell, I suppose you could get by with awk.
If you don't need exact output, perhaps you can use diff's --line-format=... directive to inject actual line number in a diff, rather than the word you removed in preprocessing step.

Paginate a big text file

I have a big text file. Each line in the file is a record. And I need to parse the text file and show only 20 records in a HTML table at a time. I will have to support sorting as well.
What I am currently doing is read the file line by line based on the parameters start, stop, and page_size which is provided in querystring. It seems to work fine until I have to sort the records, because in order to sort I need to process every line in the text file.
So is there a Unix command which can I extract from line to line and sort? I tried grep but I do not know enough it to get this problem solved.
Take a look at the pr command. This is what we use to use all the time to paginate big files. You can set the page length, headers, footers, turn on line numbers, etc.
There's probably even a way to munge the output into HTML.
How big is the file?
man sort
Here

removing line numbers for copied code in eclipse

I am wondering if I have some code with line numbers embedded,
1 int a;
2 MyC b;
3 YourC c;
etc., and then I copy them and try to paste them in Eclipse, how to get rid of these line numbers to make the source code valid? Is there any convenient way, or a short-cut key?
Thank you.
Simply use the Alt+Shift+A (Eclipse 3.5 M5 and above) shortcut to toggle block selection mode. Then select the column with line numbers and delete it!
To make it easier you could setup a macro, but for that you need additional plug-in. I'm not aware of how to do it even easier.
Try this link. This is a dynamic online tool, where it is very easy to just copy paste code and get code without line numbers:
http://remove-line-numbers.ruurtjan.com/
You could use some script to do the work. For instance, using sed
I removed line numbers by find and replace with regular expression option.
Replacing regular expression \d+\s\s with empty string where \d+ means any combination of numbers and \s is actually a space (This is to avoid any numbers present in the code).
Best way is use SED command. Here you can specify as many as digit you want to replace.
in below example open copied code in VI editor and assuming its containing upto 1000 lines.
:%s/^[0-9][0-9|10-99|100-999]//g
if you want to use more lines then put one more or condition.

When comparing two files, how can I get the exact line number of changed locations?

I need to compare two source files and obtain the exact line number of changed statements. I used GNU diff and output in a unified format. However, this output only shows the changed chunk (identified by line ranges). But what I really want is some tool that can directly give me this:
(about the new file)
line 5: added;
line 11: modified
(about the old file)
line 7: deleted
Is there any tool that can achieve this? Or is there any option in GNU diff that can achieve this?
Thank you!
Graphical tools like meld or kdiff3 show both files with line numbers. Maybe it is what your are looking for.