What is tail -n0 -f vs tail -n1 -f [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 10 months ago.
Improve this question
I have wrote a simple script to keep monitor log file and append line and have implement some if statement if memet.
From my understanding, tail -n0 -f and tail -n1 -f both will does the job where you tell your script to keep monitor this log file of last line at the time and append one at the time.
Key thing is last line.

tail -n0 -f print NO lines, then waits for incoming new lines.
tail -n1 -f print the last line of the input file, then waits for new lines.
If no -n is provided, it defaults to 10.

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];'

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

How to delete file named "-d" in unix(Mac OSX) from 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 8 years ago.
Improve this question
I was playing with tail, head, cut and awk commands on a text file and somehow these commands created empty files with names "-d" and "-f2" (It could be due to ). Now I am not able to delete these files from command line since all commands take these as options. Of course I can delete these from Finder but I am wondering how to delete these from command line.
Use -- to separate the files from the command line arguments. That is
rm -- -d -f2
Or, you can use the full path or a relative path containing at least a /:
rm ./-d ./-f2

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

How to fetch cpu utilization of a particular process 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 8 years ago.
Improve this question
I have used following command to fetch the CPU utilization of a process. It is giving result, but it is not coming out. I have used following command.
top | grep <processname>
I just want to put this in a loop and I will insert sleep in the code so that I can fetch the value in regular intervals
Use top's batch mode, eg.
top -b -n1 | grep processname
You can do:
while [ 1 ]; do top -n 1 | grep something; sleep 1; done
Use the -n option of top:
-n
Number of iterations. Update the display this number of times and then exit.

Resources