Skip to content

Magenaut

  • Home
  • Topics
    • Notes
    • Tutorial
    • Bug fixing
    • Extension
    • Server
  • Q&A
  • Privacy Policy
  • About

grep

Grep of many keywords over many files: speeding it up

August 8, 2022 by Magenaut

I am currently facing a “performance problem” while using grep. I am trying to locate the occurrences of many (10,000+) keywords in many (think Linux kernel repository size) files.
The objective is to generate a kind of index for each keyword:

Categories Q&A, Unix & Linux Tags grep, performance, shell Leave a comment

Match two words that is on the same line

August 7, 2022 by Magenaut

The command that I have prints out two of the lines whenever FW_6.0.0 is found, below is the code:

Categories Q&A, Unix & Linux Tags grep, sed, text-processing Leave a comment

Limit grep context to N characters on line

August 7, 2022 by Magenaut

I have to grep through some JSON files in which the line lengths exceed a few thousand characters. How can I limit grep to display context up to N characters to the left and right of the match? Any tool other than grep would be fine as well, so long as it available in common Linux packages.

Categories Q&A, Unix & Linux Tags grep, json, search Leave a comment

What are the exact differences between awk and cut with grep?

August 7, 2022 by Magenaut

We know that we can get the second column of the line we want from a file using these two techniques: awk '/WORD/ { print $2 }' filename or grep WORD filename| cut -f 2 -d ' ' My questions are: What are the differences between the two commands above? Which one has the best … Read more

Categories Q&A, Unix & Linux Tags awk, cut, grep, performance Leave a comment

How do I pipe ls to grep, and delete the files filtered by grep?

August 7, 2022 by Magenaut

I wanted to delete some package in my home file, but the filename was too long (google-chrome-stable_current_i386.deb). So, I decided to use the command ls|grep chrome|rm to pipe the files to grep to filter out the chrome file, and then remove it. It didn’t work, so I would like to see how I can do this.

Categories Q&A, Unix & Linux Tags grep, ls, pipe, rm Leave a comment

Counting occurrences of word in text file

August 7, 2022 by Magenaut

I have a text file containing tweets and I’m required to count the number of times a word is mentioned in the tweet. For example, the file contains:

Categories Q&A, Unix & Linux Tags cut, grep, text-processing Leave a comment

grep lines starting with “1” in Ubuntu

August 7, 2022 by Magenaut

I try to search for lines that start with “1” using

Categories Q&A, Unix & Linux Tags grep, regular-expression Leave a comment

grep the man page of a command for hyphenated options

August 7, 2022 by Magenaut

When I grep the man page of the find command for matches to type it returns a lot of search results that I don’t want. Instead I want to use a command that returns only the search results for -type.

Categories Q&A, Unix & Linux Tags grep, man, options Leave a comment

grep files from list

August 7, 2022 by Magenaut

I am trying to run grep against a list of a few hundred files:

Categories Q&A, Unix & Linux Tags bash, command-substitution, grep, process-substitution Leave a comment

How to add a carriage return before every newline?

August 7, 2022 by Magenaut

I have a file that only uses n for new lines, but I need it to have rn for each new line. How can I do this?

Categories Q&A, Unix & Linux Tags grep, newlines, sed Leave a comment
Older posts
Newer posts
← Previous Page1 … Page7 Page8 Page9 Page10 Next →
  1. michealSmith07 on Is there a way to dynamically refresh the less command?August 21, 2022

    That is a very nice post. I like this post.

  2. anonymous on Fix libwacom9 dependency issue when upgrade DebianJune 27, 2022

    saved my day!! Thanks for the help…

  3. sreedhar on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    Thanks its working

  4. saintnick on Fix libwacom9 dependency issue when upgrade DebianMay 10, 2022

    remove libwacom2 worked for me as well

  5. ranafoul on Fix libwacom9 dependency issue when upgrade DebianApril 22, 2022

    apt remove libwacom2 helped on kali 2022.01. gr8

.net ajax asp.net asp.net-core asp.net-mvc asp.net-mvc-3 asp.net-mvc-4 asp.net-web-api bash c# command-line css custom-post-types custom-taxonomy dataframe dictionary django entity-framework functions gridview html iis javascript jquery json linux list matplotlib numpy pandas php plugin-development plugins posts python python-2.7 python-3.x security shell shell-script sql string vb.net webforms wp-query

© 2026 Magenaut • Built with GeneratePress