Most voted "grep" questions
grep is a command-line application for Unix/Linux systems that searches the contents of files (or input) for lines that respect the mentioned regular expression. All lines found are shown in the standard output (usually the monitor). If the question is not about "grep", do not use this tag, even if you are using "grep" in your project.
Learn more…16 questions
Sort by count of
-
20
votes3
answers25651
viewsWhat is the equivalent of the grep command in Windows?
Under Linux, when I want to filter by a term when a command will generate giant list, I use the command grep. For example: ls | grep "termo" However, in Windows there is no command grep. What would…
-
5
votes3
answers115
viewsRegular expression of citations in R
I would like to extract all reference keys I use in a document markdown beginning with the character @. Here is an example of the different ways I can quote a document using this key: line <-…
-
3
votes1
answer84
viewsSimilarity of elements in different vectors
I have two vectors: A <- c("RS", "DF", "CE") B <- c("Porto Alegre - RS", "Brasília - DF", "Fortaleza - CE", "Porto Alegre - RS", "Acre - AC", "Recife - PE") and a function: f <-…
-
3
votes2
answers413
viewsHow to copy files from one directory to another using regex?
On the linux terminal, when I want to list files in a directory using regex, I do: #exemplo listando arquivos começando com uma letra maiúscula ls | grep -oP '^[A-Z].+' The flag oP is used for…
-
3
votes2
answers35
viewsHow to select rows that have text searching in all columns of a data frame
I want to select only the lines that have the text "Try", similar to grep in Linux. Follow the example: my.data <- data.frame( A = c("prot trypsina catalic", "7", "123", NA, "1419", "ab", "ab",…
-
2
votes2
answers81
viewsHow to print Ipv6 Global using grep and awk?
It’s been a few days since I’ve been searching the Internet for such an answer, but I haven’t had one so far. I am trying to print Ipv6 Global from ifconfig to be used in MOTD on Ubuntu. With Ipv4…
-
2
votes1
answer135
viewsCreating a file from a list and several different files
I have a list of names and several different files that may or may not contain all the names in the list and a value assigned to the names. I need to compare the values of all these each file to the…
-
2
votes1
answer78
viewsPick up commits with keywords
I’m trying to mine some Git data, I need to know how many commits the X file is in and if in those commits I have a keyword for a list. I’m using the following command: git log --all --grep fix…
-
2
votes1
answer26
viewsFilter two lines of the file at the same time show only the second?
I have the following fictional file: Location: Estado Title: Bahia Location: Estado Title: Pernanbuco Location: Estado Title: Alagoas Location: Cidade Title: Recife Location: Cidade Title: Barretos…
-
1
votes2
answers266
viewsHow to search for old files on Linux?
I need to use the command tail -f, to do a search on logs bygones. I know there’s a tail -f | grep "". But I don’t know how to find the old ones with the parameter I want. Can someone help me?…
-
1
votes1
answer60
viewsRedirect standard HCIDUMP output using GREP to a file
I am using a shell script to do HCIDUMP and using some filters to write to a file. With the following command, the destination file is empty. hcidump -a l2cap | grep -v -e 'CAP' -e 'HCI' >…
-
1
votes3
answers102
viewsLinux - Edit multiple files using another file as source
I have a file (list name.txt) with several names, one per line. I need to edit or remove all the names that are on listanome.txt of several other files With grep I think which files should be…
-
1
votes1
answer28
viewsHow do I egrep print the matchlist of a file?
I’m reading a book of regular Expressions where the author uses egrep to show some examples. It happens that when I try to replicate the examples on my computer my output is different from the one…
-
1
votes1
answer38
viewsI need to delete the line that matches a word in the first file and also the second file in the sequence. How do I do?
I need to delete an entire line through a word that I will define and at the same time delete another line as well, but now it must be in another file that corresponds to the line of the first file.…
-
0
votes1
answer26
viewsHow to search within a file in different subfolders using grep?
How can I make a grep searching in a specific file but within several subfolders? Something like grep -R "busca" /home/apps/*/teste.php The asterisk is the indication that I want to search in all…
-
-2
votes1
answer104
viewsexecute grep command in C language and return result
void main() { char comando[2000]; char resultado[500] sprintf(comando, "grep '[0-9]{50}-' input.txt); resultado = system(comando); printf("%s\n",resultado); } I only need 1 match, and return the…