I have file test1.txt file, i am trying to read variable which is enclosed in double quotes and starting with hyphen for eg: “-color”. i trying to use this grep command cat test1.txt | grep getParm | sed ‘s/getParm(/ /;s/&/ /;s/,/ /;s/”/ /g’ | awk ‘{print $3}’ , where i am not able to read exact data for all variables
Tag: grep
How to find the lines that include same two letters by using grep?
For example “Conclusion” has two c but at different index. I am using It shows me only like “Accept”. I mean it shows me only these words are with side by side but i want to see here also “Conclusion” Answer If you plan to match lines that contain any two identical letters that are not necessarily consecutive, you can
Bash script how to display matched words in custom order
The following is the output of the command ads2 cls create However, I’m trying to extract the value of name and state for each node, save them in a variable and display them in the following order: Till now i, with the help of this so much powerful learning site, could extract the values of name and state by executing
grep -r –include not works but –exclude works
In bash, What’s the problem? Answer You are using curly braces incorrectly. The correct syntax would look like (Notice also the addition of the missing file name argument . at the end.) You can see what’s going wrong by putting an echo in front and examining what the shell expands the braces to.
linux grep match a subset of files from a previous match
I am needing pipe this result: to another grep: ie. “files that extend Some_Critical_Class that also have function init()” If there is a way to do it in one operation in grep, that would be great, but I’d also like to see the how the piping is done to improve my programming in *nix (which is rudimentary right now). Thanks.
Trying to find empty files in other user home directory
I want to search for empty files inside the home directory of the user “adam” for example. Now i don’t know the right path for that user, so I need to get it from /etc/passwd with the following command: Output: /home/adam (for example) Then executing this command to find the empty files. Is it possible to do this with one
How can I find the number of 8 letter words that do not contain the letter “e”, using the grep command?
I want to find the number of 8 letter words that do not contain the letter “e” in a number of text files (*.txt). In the process I ran into two issues: my lack of understanding in quantifiers and how to exclude characters. I’m quite new to the Unix terminal, but this is what I have tried: I need to
bash – print regex captured groups
I have a file.xml so composed: I need to extract the following information: mayor_and_minor_release_number –> 1.0 patch_number –> 13 suffix –> -alpha I’ve thought the cleanest way to achieve that is by mean of a regex with grep command: I’ve checked with regex101 the correctness of this regex and actually it seems to properly capture the 3 fields I’m looking
using grep commands to find a duplicate id within a json file
I am looking for a way to use grep on a linux server to find duplicate json records, is it possible to have a grep to search for duplicate id’s in the example below ? so the grep would return: 01 Answer OK, discarding any whitespace from the JSON strings I can offer this if awk is acceptable – hutch
Extracting a set of characters for a column in a txt file
I have a bed file (what is a txt file formed by columns separated by tabs). The fourth column has a name followed by numbers. Using the command line (Linux), I would like to get these names without repetition. A provided an example below. This is my file: My list should look like this: Could please help me with the