Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 6 years ago. Improve this question Replace very near string to a number with another string How to replace
Tag: grep
Using grep and * to get the exact file name
I have following heapdump files now if I use I get following output But I use I get no output. Could anybody help where is my mistake and how to search the heapdump files. My expected output is should give me due to some reason I could not use Answer It looks like you’re confusing glob patterns with regular expressions,
grep multipe wildcards in string
Say I have a file that contains: I want to grep and match lines that only contain ‘package’, ‘el6’, and ‘x86_64’ How would I go about doing that on a one liner using grep? The line must match all three and grep shouldn’t care about how many characters are in between. If there is a better tool for the job,
How can I extract the text portion of a binary file in Linux/Bash?
I have a binary file. If I open it with vi, it shows sequences of human-readable text and binary characters. What is the best way to extract the human-readable portion only using Bash? I was thinking, maybe we can do this over a grep or sed pattern? Answer Use the strings utility – that’s exactly what it’s designed for.
partial merging 2 text file in linux
I have 2 text file which I want to merge them in a new file. my first file is look like and second file = and my expected output like, I mean mapping part of 9th column string from first line with 1st column of second file, should be like : Also, I wanted to keep line from first file
Color information disappears when writing a result of ‘grep –color=auto’ into a file
When I do as below with an aliased grep(grep –color=auto) it returns abcde (ab in red). but foo.txt has just abcde. I guess my terminal shows ab in red in the 1st case according to some tags by ‘grep’ but foo.txt does not contain them. Is it due to grep? Does grep judge what returning value should be? My grep
Compare columns from two files and print not match
I want to compare the first 4 columns of file1 and file2. I want to print all lines from file1 + the lines from file2 that are not in file1. I don’t understand how to print things that don’t match. Answer You can do it with an awk script like this: script.awk And run it like this: awk -f script.awk
Extract text with any command in linux shell
How do I extract the text from the following text and store it to the variables: Here, I want to store 05 in one variable, 21 in another, 09 in another and so on. All the value must me stored in array or in separate varibles. I have tried: I need a more clear solution or short solution. Answer Your
Finding a string between two lines in a file using linux commands
I have a file, file.txt, like this: What I want to get is the line between the last set of ‘start cal’ and ‘end cal’. I am using tac and grep to do it. But in vain. Any help please? Below is my code: What am I doing wrong? For the example above, I need the command to return ‘error’.
Negative lookbehind assertion regex has unexpected result with grep -P
I’m testing the following negated lookbehind assertion and I want to understand the result: it prints out I was expecting that only the two first foo would be printed, ‘echo foo foofoo’ but not the third one, because my assertion is supposed to mean find ‘foo’ that is not preceded by a ‘foo’. What am I missing? why is the