Questions tagged [tail]

Watching updates at the end of a file, with or without the tail utility

Filter by
Sorted by
Tagged with
1 vote
1 answer
37 views

bash looping over files while tailing logs

I'm running a daemon that process files in a specific dir. I want to process those one by one. so idea is I will copy files 1 by 1 in daemon dir, and tail its log, 2nd file should be copied to daemon ...
user avatar
  • 1,703
1 vote
3 answers
61 views

How to suffix or prefix each line coming from tail command

I have a file and I am running a tail command on this file like this tail -n+1 -F "./log/catalina.log" I want to suffix or prefix another string to each line coming out of this file, which ...
user avatar
0 votes
0 answers
54 views

SCP results look strange when using >> to append to file

I am trying to record a reoccurring test to a txt file using tail but there is an issue with the output. The commands I am running are: script -q /dev/stdout -c 'scp /home/user/test.img user@pc28:/tmp'...
user avatar
  • 1
0 votes
1 answer
31 views

Can I pipe live data from the \watch command of postgresql into another command?

I'd like to pipe live data from psql into another command for purposes of monitoring via the shell. Can this be done? So far I have the following: $ psql bareos -c '\watch (SELECT * FROM log ORDER BY ...
user avatar
  • 4,109
0 votes
0 answers
44 views

tail -f executed of ssh repeat output multiple times

I am trying to monitor a file remotely. Since I cannot install additional useful applications on the source I plan to use tail over ssh to bring the information local where I have more options. Since ...
user avatar
3 votes
2 answers
90 views

piping head and tail with globbing

I have several files in the same dir for which I want to print certain lines from a continuous interval, e.g., from 15th to 20th. For a single file, this works head -n20 file.txt | tail -n6, but how I ...
user avatar
0 votes
0 answers
16 views

why doesn't tail -f log.txt | cut -f1 | nl produce any output? [duplicate]

tail -f log.txt | nl works fine. tail -f log.txt | cut -f1 works fine. but tail -f log.txt | cut -f1 | nl produces no output, why is this?
user avatar
  • 3,268
0 votes
2 answers
111 views

Get the nth last line from file

I have a file with quite many lines, and I would need the nth last line (specifically the 95th from bottom). How could I go on about doing this? One way would be to use tail but then it prints ...
user avatar
1 vote
1 answer
29 views

How to add empty new lines in less (log viewer)?

When I monitor some log file with tail -F file.log, I can press enter to add some space between actual log lines and the new ones, for example: some log 1 some log 2 some log 3 some log 4 some log 5 ...
user avatar
  • 599
0 votes
0 answers
19 views

Discard Output Of Process but Allow Tailing (Within A New Session) As Needed

I have many processes that I run in the background that are redirected to /dev/null. I restart these processes in a new session in the event I need to see their output. I'd like to be able to tail ...
user avatar
  • 204
0 votes
2 answers
98 views

how to invoke sed from awk while following logfile?

I'm supposed to follow a logfile, I want to initiate a sed command to edit conffile upon appearance of certain line in the log. I did little research and found out that it can be done with awk. and ...
user avatar
  • 1,703
0 votes
0 answers
12 views

How can I tail -f a wildcard pattern, and have files created after the command be included? [duplicate]

If I tail -f *.log in a directory that has 3 matching files, all of those files will be tailed, but any files created after the launch of that command will be missed out. How can I have tail watch for ...
user avatar
0 votes
0 answers
108 views

Tail and watch, filter and extract string [duplicate]

Lets says I have a file called test.log more rows being added all the time: one|two|apple|four|foo1 one|two|pear|four|foo2 one|two|apple|four|foo3 one|two|peach|four|foo4 I want to tail it but am ...
user avatar
  • 111
2 votes
1 answer
110 views

No output: busybox find . -exec sh -c ' readlink -f "$1" | tail -n +2 ' sh {} \;

I got access to only Busybox 1.31.1 I originally wanted to remove the current working directory of my output (the single dot). Example: /prueba$ ls uno dos tres When I: $ busybox find . . ./uno ./dos ...
user avatar
  • 143
1 vote
1 answer
48 views

Unix Script - On specific pattern, need to exit tail -f, and use awk to run separate script

So, I need to make a modification to a start script to clean up the /tmp once the application is fully loaded. After some research, I found a command for my script that does this: tail -f /home/user1/...
user avatar
  • 133
0 votes
0 answers
58 views

script in bash two if condition and print in for loop

I'm learning to script in bash, trying to solve a little exercise. The exercise is this: If the variable named "basenew" contains the contents of the variable named "valuebase". &...
user avatar
  • 11
1 vote
1 answer
103 views

less in "tail -f mode" and ability to scroll horizontally at the same time

less -S is useful to have horizontal scrolling with arrow keys (like mentioned in Horizontal scrolling in smaller increments with less -S) instead of breaking long lines into multiple lines less +F, ...
user avatar
  • 2,163
2 votes
1 answer
137 views

How to properly use tail to concatenate all hidden files [duplicate]

Issue I want to be able to : concatenate all files in a directory (regular and hidden), but I would also like to display the title of each file at the beginning of each concatenation. I found some ...
user avatar
  • 135
1 vote
2 answers
74 views

Efficient header replacement for large (10M line) files?

I am trying to rename the column headers of a large file, and I want to know the most efficient way to do so. Files are in the range of 10M to 50M lines, with ~100 characters per line in 10 columns. A ...
user avatar
  • 111
1 vote
1 answer
50 views

how to logresolve httpd log file to /dev/null and tail it?

I would like to watch traffic live (httpd log activity) , I currently use tail -f /var/www/access.log It works fine , its live, however just want to convert ip address to hostnames, i dont want to ...
user avatar
0 votes
1 answer
167 views

Why isn't tail command tracking the changes in a file in realtime? [duplicate]

When I track a file in realtime using descriptor i.e tail --follow=descriptor file_name, it doesn't show the changes made in the file, whereas if i track the file in realtime using name i.e tail --...
user avatar
1 vote
5 answers
224 views

Pipe skip 99 lines out of every 100

I have a bash commands pipeline that produces a ton of logging text output. But mostly it repeats the previous line except for the timestamp and some minor flags, the main output data changes only ...
user avatar
1 vote
1 answer
231 views

tail -1 file1 >> file2 without \n

it might be simple but after looking around I could not find a way to resolve my issue, I am recovering the last line from file1 using tail -1 file1 and want to add it to an existing file that is a ...
user avatar
0 votes
1 answer
277 views

Bash - "timeout" with tail issue

timeout 0.6s $(tail -f ./file.txt | grep -qA2 --line-buffered "detail: " | grep -E -- "$KeyNumbers") So timeout isn't functioning as intended with this. I want it to cancel if ...
user avatar
  • 3
0 votes
1 answer
140 views

"tail -f | grep -q" as a trigger without worrying about the previous found

Currently, the only way to see if my Tomcat has fully started up is to check apache-tomcat log: tail -f ./catalina.out and look for this pattern to show up before I do any job. org.apache.catalina....
user avatar
  • 247
2 votes
2 answers
73 views

Live tail from different folders with inclusion and exclusion of files

I want to live tail from three different folders with certain files included & excluded. Folder 1: Path: /var/www/app/var/log/ Exclude only: file1.log & file2.log Folder 2: Path: /var/log/...
user avatar
0 votes
0 answers
70 views

why SIGPIPE behaves different in different kernels?

I have two different systems running with linux and I'm getting some logs with tail -f logfile While tail was running, I sent SIGPIPE to tail's process. tail continued to run on system 1 but died ...
user avatar
1 vote
1 answer
86 views

How to paste multiple commands output into single output file

I have txt file that I have to swap the first paragraph with last one. I did it but now I don't know how to paste everything in a new txt file. This is my command tail -14 gl.txt ; head -n 74 gl.txt | ...
user avatar
  • 13
0 votes
3 answers
151 views

How can I continuously concatenate files in a directory such that I see the last lines of the newest file?

I have a script that listens to Twitter and stores tweets with a certain keyword in a JSON file. A new destination file is created every time the script starts. Sometimes my script crashes and ...
user avatar
0 votes
1 answer
73 views

Output large file entirely in follow mode similiar to tail -f

Is there a command to output a large file and follow on directly in the shell stdout? I am aware of less +F or I could simply use tail with an ultimately high n like tail -f -n1000000 if the file is ...
user avatar
  • 158
1 vote
1 answer
64 views

How to track all shortcut keys pressed and the process they interact with?

For a while now and for some reason I find myself in the unpleasant situation of Ctrl-w not working anymore in any program, which means I need the mouse any time I want to close a tab. I tried ...
user avatar
  • 45
-3 votes
1 answer
64 views

I am learning how to use grep and came across this. How does it work? [closed]

What would grep '#' input.txt | tail -n give me? I am new to this and cannot figure out what happens using grep and tail together.
user avatar
1 vote
0 answers
42 views

How to find if the tail command will work on a given file [duplicate]

I let the user specify a filename say hello.txt and the number of newest lines say 30 they want from the file. I then fire the below command to get them the data they are looking for. tail -30f hello....
user avatar
  • 307
2 votes
1 answer
102 views

awk behaving different with tail vs inotifywait

awk behaves differently when analyzing the output of tail -f versus inotifywait -m. Specifically I am searching for a matching string and want to exit awk once it appears. This works fine for tail -f, ...
user avatar
  • 10.8k
0 votes
1 answer
264 views

run command after every line of grep output appears

I'm wanting to constantly monitor syslog and perform some computations after a regex pattern appears, and use the grep output in the command, as well as continue to monitor for new matching lines. The ...
user avatar
  • 486
0 votes
1 answer
83 views

Monitoring a file and executing a command based on changes to that file

I am searching for a way to execute a command when a keyword appears in a given file, say temp.txt. Currently, I have tried tail -F temp.txt | awk '/keyword/ {echo found}'. The desired goal is for ...
user avatar
-1 votes
1 answer
616 views

ls |head (offset?)

Is there a way to paginate the ls command? For example, to get the first 50 items I can do: $ ls -U |head -50 How would I then do: $ ls -U | head -50 "offset 50" Or, does this require to ...
user avatar
  • 319
0 votes
1 answer
83 views

Collect every n lines from a file

I have a huge log file, which needs to be streamed over HTTP. For performance reason, I want to capture/collect every n lines and send it over. So, basically, what I want is n lines buffered output ...
user avatar
3 votes
0 answers
32 views

`tail -qf *.log`, except pick up new files too [duplicate]

I have multiple processes doing some computation; they routinely come and go, and often work in parallel. I'd like to have a single tmux window following their logs—all of them together. I've tried ...
user avatar
  • 572
5 votes
1 answer
597 views

"tail -s N" does not sleep for N seconds before updating

The manual for GNU tail says -s, --sleep-interval=N with -f, sleep for approximately N seconds (default 1.0) between iterations; with inotify and --pid=P, check process P at least once every N ...
user avatar
3 votes
2 answers
750 views

How to stop the tail when sed finds the string? [duplicate]

I want to terminate the tail command after having the match found and until then all the lines are written to another file. tail -f logfile | sed '/special string/q' | tee output.txt Output.txt will ...
user avatar
1 vote
3 answers
469 views

How to show a real-time count of the number of lines added per second to files?

I'm working with a directory of multiple log files. I'm trying to show a running count, updated periodically, of the number of lines written to each log file. I need to see the number of lines written ...
user avatar
  • 263
3 votes
2 answers
149 views

merging 5 million files efficiently

Due to some poor planning i have a directory containing > 5 million files totalling roughly 20GB. Each file contains 32 lines of garbage at the top followed by an unknown number of lines of ...
user avatar
0 votes
4 answers
529 views

How to 'tail' a logfile, X lines at a time

I have a logfile that is generating hundreds of lines per second – say, 12 specific lines, 16× per sec. I want to run either a command-line or a shell script that can display this logfile neatly in ...
user avatar
3 votes
3 answers
671 views

Display last n lines of the output of a command

I am trying to run docker build command. I wanted to see only last 'n' lines of the output continuously. For example, usual docker build command give me something like: Building myimage Step 1/15 : ...
user avatar
0 votes
1 answer
208 views

tail -f -n 1 returns all content of the file

I have a text.txt file in Ubuntu. I want to watch the file with tail for grabbing the last content of the file. tail -f text.txt this command returns all of the content. So I changed it to : tail -f -...
user avatar
0 votes
2 answers
226 views

Using tail -f together with sed and xargs

Suppose I have the following process to write a number + single quote to the file /tmp/test every second: for i in {1..1000} ; do echo $i\' ; sleep 1 ; done > /tmp/test I then want to use tail -f ...
user avatar
  • 400
4 votes
0 answers
89 views

Why does 'tail -c 10K' cause it to read an entire 16GB flash drive?

To view the last 10K of a 128GB internal SSD I used: sudo tail -c 10K /dev/sda | xxd This worked as expected and immediately output the data. However when I try to view the last 10K of a 16GB USB ...
user avatar
  • 3,583
0 votes
1 answer
144 views

Using Tail on a process causes character input delay & disruption [duplicate]

I was referring to this question to see if it is possible to spy on another running process' stdout. One answer suggests using tail -f /proc/<PID>/fd/1 to do so. So I opened two terminal ...
user avatar
1 vote
0 answers
71 views

Inconsistent behaviour when piping output of Tail into Xargs through an editing command

I'm giving in to asking the SE spirits for assistance. I will expand in detail below, but I've boiled the inconsistency down to these 3 lines. I am trying to grep a string in between single quotes (...
user avatar
  • 312

1
2 3 4 5
8