Two string compare after grep [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I got the following line
2020-10-17 14:55:39,586 INFO [http-bio-exec-60] [] [D88E13F571A51598613FAA078A215326.server.host.com.:9991] [some.package.Class] TEST_STRING - RSI: 506B48ECADC4BE0CEBF7C7D33D036B67.server.host.com.:9991
I do grep "D88E13F571A51598613FAA078A215326" and got the line above. Is there a way to run a command after grep to check if D88E13F571A51598613FAA078A215326 and 506B48ECADC4BE0CEBF7C7D33D036B67 are equal?
Thanks.

This will work if you already know the first pattern:
PATTERN=D88E13F571A51598613FAA078A215326
grep "\[$PATTERN.*RSI: $PATTERN" input_file

I got the following line, that's not a good way to start here:
Your line contains quite some information, and as mentioned in the comments, you might parse it using Perl or awk or any other tool, but I would advise otherwise: how do you get this line (I guess it's an output of some process)? You might ask the author of that other process to alter the output in such a way that it's easier for you do parse it and do the comparison you're aiming for.

Pipe grep output into this Perl one-liner, which splits the line on non-word characters and prints it if fields 13 and 23 are identical as strings:
echo '2020-10-17 14:55:39,586 INFO [http-bio-exec-60] [] [D88E13F571A51598613FAA078A215326.server.host.com.:9991] [some.package.Class] TEST_STRING - RSI: 506B48ECADC4BE0CEBF7C7D33D036B67.server.host.com.:9991' | \
grep 'D88E13F571A51598613FAA078A215326' | \
perl -F'/\W+/' -lane 'print if $F[12] eq $F[22];'

Related

Exclude rows on "shuf" command [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
I have a csv with 100 rows, i want shuffle all rows skipping the first 2, but i dont find how exclude the first 2 lines
Now it is like this:
shuf words.txt > shuffled_words.txt
Can somebody help me?
The shell lets you easily combine text and file manipulation commands using pipes.
sed 1,2d words.txt | shuf >shuffled_words.txt
There are many ways to skin this cat; tail -n +2 words.txt or awk 'FNR>2' words.txt are also common and idiomatic ways to remove the first two lines.
Or something like this:
( head -n 2 words.txt ; tail -n +2 words.txt|shuf ) > shuffled_words.txt

Linux regular expression command [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 3 years ago.
Improve this question
What command would you give to list all English-language words that are exactly 5 characters long and that begin with an upper or lower-case vowel (‘a’, ‘e’, ‘i’, ‘o’, ‘u’, or ‘y’), have a lower-case ‘t’ in the middle position, and end with a lower-case ‘s’?
The remaining letters could be any character that occurs in English words, including but not limited to upper and lower-case alphabetics, numbers, hyphens, etc.
You had it almost!
grep ^[AaEeIiOoUuYy].t.s$ /usr/share/dict/words
Since I prefer complex pipelines to complex regular expressions, here's my take:
cat /usr/share/dict/words \
| grep -E -x ".{5}" \
| grep '^[aeiouyAEIOUY]' \
| grep '..t.s'
(Useless use of cat added for readability).
On my Ubuntu it produces this output:
Art's
Estes
Oates
Oct's
Yates
act's
altos
ant's
antes
antis
art's
autos
iotas
oat's
oaths
out's
(You can replace .{5} with \w{5} or with [a-zA-Z0-9-]{5} or whatever you like).
I've actually written a similar script to chea.. I mean, help me with crosswords.

How to list directories which are contains only two letters? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I want to make a command where I list that directories which are contains only two letters.
How can I do it?
? is a wildcard for one character. So, the following should work:
ls -d ??/
The -d prevents ls from listing the contents of the directories, the final / excludes files.
ls -F | grep -o "^.\{2\}/$"
ls -F lists content by file system object type
| grep -o filters out anything that doesn't match the regex expression ^.\{2\}/$ which basically says 'match only folders with 2 characters in their name'
ls */ | awk 'length($0) < 3'
Note that this does not match hidden directories. choroba's answer is better, because it is usually a bad idea to parse the output of ls, but I like this for its readability.

Is there a trick to show detail description of specific command option in linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
Is there a trick to show linux command's specific option? Such as I want to know some detail about tar's -z option, and I try this: tar --help | grep '-z' but shows nothing.
So is it possible just show details about specific command option?
Appreciate first if you can help me.
Specifically for the problem of tar --help | grep '-z' not working, do this:
tar --help | grep -- '-z'
Without the --, grep takes -z as an option rather than an argument.

Three | commands in linux terminal [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
Normally in a Linux command you can specify another one to be run at the same time like this:
ls | grep "sys"
for example. In my case I have this command:
urlsnarf -i wlan0
and I can edit it like this to show filtered output:
urlsnarf -i wlan0 | cut -d\" -f4
but I also want to save the output to file and at the same time print text in the console so I edit it like this:
urlsnarf -i wlan0 | cut -d\" -f4 | tee output
but there is neither an output file nor printed output. Is there any way to fix this?
I imagine what's happening here is the pipe is being buffered. I haven't seen urlsnarf before, but it looks like it's a continuous monitoring process. According to the following post, you can't easily stop the pipe from being fully buffered:
How to make output of any shell command unbuffered?
The article linked from an answer there is a good read: buffering in standard streams

Resources