Three | commands in linux terminal [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 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

Related

Two string compare after grep [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 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];'

How to paste what is on clipboard, sort and put it back to the clipboard [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 would like to know if it's possible somehow to paste what it's in my clipboard into the terminal, sort it, and then put it back to my clipboard. I used to use the following command on OSX:
pbpaste | sort | pbcopy
Since I've changed to Linux I haven't managed to find a way to do the same thing.
You could use the xsel utility
xsel -o -b | sort | xsel -i -b
xsel allows you to manipulate input output including the clipboard. So you're reading the clipboard content and outputting to stdout with
xsel -b -o
Then passing that output to sort with the pipe, and then reading the stdout of sort into
xsel -b -i
Which takes the stdout of previous commands and sets it to your clipboard
EDIT : The -b flag specifies to use clipboard

Who try to access root# [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 5 years ago.
Improve this question
I couldn't find how i can have the list of IP that try to access my root# (it is a command in Linux but i couldn't find it). And than how can I block an IP from this access.
There is someone that try to access my root# on the server. I need to resolve this problem.
I tried this but don't work :
cat access.log| awk '{print $1}' | sort | uniq -c |sort -n
Just type:
last root
This will give you details of the IP addresses of machines where users logged in as root.
Without knowing your Input_file I am providing this solution, so could you please try following and let me know if this helps you.
awk '{match($0,/[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/);array[substr($0,RSTART,RLENGTH)]} END{for(i in array){print i,array[i]}}' Input_file
If above is not helping you then kindly show us sample Input_file and expected output file too in code tags, so that we could help you in same.

unlimited scrolling up from default linux command line [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 7 years ago.
Improve this question
I am looking to increase the default size of the scrolling up buffer from linux command line. It is a Debian server without gui.
I don't find related option in bashrc and I don't even know if there is other configuration file for the default prompt alt+f1 alt+f2 ...
You can change the scrollback-buffer size using kernel options as described here: https://wiki.archlinux.org/index.php/Scrollback_buffer .
However, if you are interested in the output of a command but at the same time you want to watch the command's progress interactively I suggest to use tee:
command | tee out.file
or if you want to append to a file use
command | tee -a out.file
tee is nice! use it! :)

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.

Resources