Tag Info

New answers tagged

1

The apropos command reads from a cache. It's possible that recently-installed man pages are not yet referenced in that cache. Generally the cache is updated either after each package installation or in a cron job, I don't know how it's set up on CentOS. To update the cache, run mandb. There may be a prefered way to run it on your distribution (e.g. as a ...


0

UI front-end for locate command that works almost the same as Everything : https://github.com/AlexTuduran/Locator/releases


0

You need to grep the entire line. This can be done as follows - x=1 len=$(wc -l file1.txt | awk '{print $1}') while [ $x -le $len ] do #pat=$(head -$x file1.txt | tail -1) << slow hence changed pat=$(sed "${x}q;d" $1) #cnt=$(grep -c "$pat" file2.txt) < Edited to count all matches cnt=$(grep -o "$pat" ...


0

Probably you could use IFS (Internal Field Separator), and assign the $'\n' to it, meaning that only newlines are the valid separator. Also, to detect multiple occurrences of the same key in the content, we could use grep -o option. Example bash script could be like the following: IFS=$'\n' for string in `cat key.txt` do $string >> out.txt grep ...


1

Try this instead: fgrep -of file1.txt file2.txt | sort | uniq -c Beware that this will only find the exact phrases. If the spacing is different, it won't find them.


0

sed -i is for inplace editing: from man sed -i[SUFFIX], --in-place[=SUFFIX] edit files in place (makes backup if SUFFIX supplied) sed is a good choice, but you could also use awk awk '/<your_pattern>/' foo > bar Example $ cat foo foo bar foobar bar foo bar bar foo $ awk '/foobar/' foo > bar $ cat bar foo bar foobar


0

You can use grep. Lets say you want search in the file source_file , and the second file where you have the lines that you want to search from is input_file. Use grep -f input_file source_file > output_file Let's say your source_file is Humpty Dumpty sat on a wall Humpty Dumpty had a great fall All the King's horses and All the ...


0

pdfgrep was written for exactly this purpose and is available in Ubuntu. It tries to be mostly compatible to grep and thus provides "the power of grep", only specialized for PDFs. That includes common grep options, such as --recursive, --ignore-case or --color. In contrast to pdftotext | grep, pdfgrep can output the page number of a match in a performant ...


3

Don't use sed -i - it would overwrite your original file. Use grep instead. grep "text to find" input.txt > output.txt


2

sed outputs to stdout by default. To output to a file, redirect sed's stdout to a file using the > operator (if you want to create a new file) or using the >> operator (if you want to append the output to an already existing file): sed '/text/' inputfile > outputfile sed '/text/' inputfile >> outputfile


0

Assuming you are using simple ftp via command line, Use dir command with -Rl option to search recursively and copy it to a file and then search the file using grep, find or whatever way is supported on your OS. ftp> dir -Rl education.txt output to local-file: education.txt? y 227 Entering Passive Mode (9,62,119,15,138,239) 150 Opening ASCII mode data ...


0

Or capitalize the terms if you want exact word matches but not necessarily consecutive and in order: [Register Indirect] will match [an indirect register] but not [register indirection]


0

One method is to first list the matching files, then read the files again to find the desired lines. This is efficient as long as the matching files aren't too large or too numerous. Assuming recent enough GNU utilities (Linux/Cygwin) to avoid problems with file names containing special characters: grep -Rlz -Fe "foo" . | xargs -0 grep -lz -Fe "bar" ...


1

With GNU awk you can do: awk 'BEGINFILE { n1=n2=0 } /str1/ { n1=FNR } /str2/ { n2=FNR } ENDFILE { if (n1&&n2) print FILENAME,n1,n2 } ' files... A variant for a list of strings to consider: awk -v s="str1 str2 str3" ' BEGIN { n=split(s,str) ; m=(2^n)-1 } BEGINFILE { f=0 } { for (i=1; i<=n; i++) if ($0 ~ str[i]) { ...



Top 50 recent answers are included