Skip to main content
replaced http://unix.stackexchange.com/ with https://unix.stackexchange.com/
Source Link

Unlike the answer to this question (Can a bash script be hooked to a file?Can a bash script be hooked to a file?) I want to be able to see content of files that haven't been created yet as or after they are created. I don't know when they will be created or what they will be named. That solution is for a specific file and actually mentions in the question title creating a "hook" to a specific file. My question is different because I don't want to hook anything, and what I do want is not specific to a particular file. My question's title specifies "..as they are created" which should be a clue that the files I am interested in do not exist yet.

I have an application that users use to submit information from a website. My code creates output files when the user is finished. I want to be able to see the content of these files as they are created, similar to the way tail -f works, but I don't know ahead of time what the filenames will be.

Is there a way to cat files as they are created or would I have to somehow create an endless loop that uses find with the -newermt flag

Something like this is the best I can come up with so far:

#!/bin/bash # news.sh while true do d=$(date +"%T Today") sleep 10 find . -newermt "$d" -exec head {} + done 

For clarification, I don't necessarily need to tail the files. Once they are created and closed, they will not be re-opened. Existing files will never change and get a new modification time, and so I am not interested in them.

Unlike the answer to this question (Can a bash script be hooked to a file?) I want to be able to see content of files that haven't been created yet as or after they are created. I don't know when they will be created or what they will be named. That solution is for a specific file and actually mentions in the question title creating a "hook" to a specific file. My question is different because I don't want to hook anything, and what I do want is not specific to a particular file. My question's title specifies "..as they are created" which should be a clue that the files I am interested in do not exist yet.

I have an application that users use to submit information from a website. My code creates output files when the user is finished. I want to be able to see the content of these files as they are created, similar to the way tail -f works, but I don't know ahead of time what the filenames will be.

Is there a way to cat files as they are created or would I have to somehow create an endless loop that uses find with the -newermt flag

Something like this is the best I can come up with so far:

#!/bin/bash # news.sh while true do d=$(date +"%T Today") sleep 10 find . -newermt "$d" -exec head {} + done 

For clarification, I don't necessarily need to tail the files. Once they are created and closed, they will not be re-opened. Existing files will never change and get a new modification time, and so I am not interested in them.

Unlike the answer to this question (Can a bash script be hooked to a file?) I want to be able to see content of files that haven't been created yet as or after they are created. I don't know when they will be created or what they will be named. That solution is for a specific file and actually mentions in the question title creating a "hook" to a specific file. My question is different because I don't want to hook anything, and what I do want is not specific to a particular file. My question's title specifies "..as they are created" which should be a clue that the files I am interested in do not exist yet.

I have an application that users use to submit information from a website. My code creates output files when the user is finished. I want to be able to see the content of these files as they are created, similar to the way tail -f works, but I don't know ahead of time what the filenames will be.

Is there a way to cat files as they are created or would I have to somehow create an endless loop that uses find with the -newermt flag

Something like this is the best I can come up with so far:

#!/bin/bash # news.sh while true do d=$(date +"%T Today") sleep 10 find . -newermt "$d" -exec head {} + done 

For clarification, I don't necessarily need to tail the files. Once they are created and closed, they will not be re-opened. Existing files will never change and get a new modification time, and so I am not interested in them.

Post Reopened by vonbrand, terdon, slm, Gilles 'SO- stop being evil', strugee
added 705 characters in body
Source Link
David Wilkins
  • 1.1k
  • 7
  • 16

Unlike the answer to this question (Can a bash script be hooked to a file?) I want to be able to see content of files that haven't been created yet as or after they are created. I don't know when they will be created or what they will be named. That solution is for a specific file and actually mentions in the question title creating a "hook" to a specific file. My question is different because I don't want to hook anything, and what I do want is not specific to a particular file. My question's title specifies "..as they are created" which should be a clue that the files I am interested in do not exist yet.

I have an application that users use to submit information from a website. My code creates output files when the user is finished. I want to be able to see the content of these files as they are created, similar to the way tail -f works, but I don't know ahead of time what the filenames will be.

Is there a way to cat files as they are created or would I have to somehow create an endless loop that uses find with the -newermt flag

Something like this is the best I can come up with so far:

#!/bin/bash # news.sh while true do d=$(date +"%T Today") sleep 10 find . -newermt "$d" -exec head {} + done 

For clarification, I don't necessarily need to tail the files. Once they are created and closed, they will not be re-opened. Existing files will never change and get a new modification time, and so I am not interested in them.

I have an application that users use to submit information from a website. My code creates output files when the user is finished. I want to be able to see the content of these files as they are created, similar to the way tail -f works, but I don't know ahead of time what the filenames will be.

Is there a way to cat files as they are created or would I have to somehow create an endless loop that uses find with the -newermt flag

Something like this is the best I can come up with so far:

#!/bin/bash # news.sh while true do d=$(date +"%T Today") sleep 10 find . -newermt "$d" -exec head {} + done 

For clarification, I don't necessarily need to tail the files. Once they are created and closed, they will not be re-opened. Existing files will never change and get a new modification time.

Unlike the answer to this question (Can a bash script be hooked to a file?) I want to be able to see content of files that haven't been created yet as or after they are created. I don't know when they will be created or what they will be named. That solution is for a specific file and actually mentions in the question title creating a "hook" to a specific file. My question is different because I don't want to hook anything, and what I do want is not specific to a particular file. My question's title specifies "..as they are created" which should be a clue that the files I am interested in do not exist yet.

I have an application that users use to submit information from a website. My code creates output files when the user is finished. I want to be able to see the content of these files as they are created, similar to the way tail -f works, but I don't know ahead of time what the filenames will be.

Is there a way to cat files as they are created or would I have to somehow create an endless loop that uses find with the -newermt flag

Something like this is the best I can come up with so far:

#!/bin/bash # news.sh while true do d=$(date +"%T Today") sleep 10 find . -newermt "$d" -exec head {} + done 

For clarification, I don't necessarily need to tail the files. Once they are created and closed, they will not be re-opened. Existing files will never change and get a new modification time, and so I am not interested in them.

Post Closed as "Duplicate" by Hauke Laging, slm, Timo, Karlson, Anthon
Additional info
Source Link
David Wilkins
  • 1.1k
  • 7
  • 16

I have an application that users use to submit information from a website. My code creates output files when the user is finished. I want to be able to see the content of these files as they are created, similar to the way tail -f works, but I don't know ahead of time what the filenames will be.

Is there a way to cat files as they are created or would I have to somehow create an endless loop that uses find with the -newermt flag

Something like this is the best I can come up with so far:

#!/bin/bash # news.sh while true do d=$(date +"%T Today") sleep 10 find . -newermt "$d" -exec head {} + done 

For clarification, I don't necessarily need to tail the files. Once they are created and closed, they will not be re-opened. Existing files will never change and get a new modification time.

I have an application that users use to submit information from a website. My code creates output files when the user is finished. I want to be able to see the content of these files as they are created, similar to the way tail -f works, but I don't know ahead of time what the filenames will be.

Is there a way to cat files as they are created or would I have to somehow create an endless loop that uses find with the -newermt flag

Something like this is the best I can come up with so far:

#!/bin/bash # news.sh while true do d=$(date +"%T Today") sleep 10 find . -newermt "$d" -exec head {} + done 

I have an application that users use to submit information from a website. My code creates output files when the user is finished. I want to be able to see the content of these files as they are created, similar to the way tail -f works, but I don't know ahead of time what the filenames will be.

Is there a way to cat files as they are created or would I have to somehow create an endless loop that uses find with the -newermt flag

Something like this is the best I can come up with so far:

#!/bin/bash # news.sh while true do d=$(date +"%T Today") sleep 10 find . -newermt "$d" -exec head {} + done 

For clarification, I don't necessarily need to tail the files. Once they are created and closed, they will not be re-opened. Existing files will never change and get a new modification time.

Source Link
David Wilkins
  • 1.1k
  • 7
  • 16
Loading