Share & learn

Through Innovative Digital Library

How to insert date and time at the beginning of each line in file by using sed command?

How to insert date and time at the beginning of each line in file by using sed command?
 



Answers

Posted by chandu on December 11th 2017 07:53 AM

1. cat reads file called input.log and just prints it to its standard output stream. Normally the standard output is connected to a terminal, but this little script contains | so shell redirects the standard output of cat to standard input of sed. 2. sed reads data (as cat produces it), processes it (according to the script provided with –e option) and then prints it to its standard output. The script "s/^/$(date -R) /" means replace every start of line to a text generated by date -R command (the general construction for replace command is: s/pattern/replace/). 3. Then according to >> bash redirects the output of sed to a file called output.log (>means replace file contents and >> means append to the end).

# cat install.log | sed -e "s/^/$(date -R)/" >> output.log
# less output.log

Posted by anonymous on June 22nd 2020 10:54 AM

spironolactone side effects [url=https://aldactonefast.com/ ]spironolactone side effects [/url] https://aldactonefast.com - spironolactone for hair loss fexofenadine hydrochloride [url=https://allegrax.com/ ]allegra d coupons [/url] https://allegrax.com - fexofenadine duloxetine 30mg [url=https://fastcymbalta.com/ ]duloxetine 30mg [/url] https://fastcymbalta.com - duloxetine

<a href="https://aldactonefast.com/">spironolactone side effects</a
[
url=https://aldactonefast.com/ ]spironolactone side effects [/url] 
https://aldactonefast.com - spironolactone for hair loss 
<a href="https://allegrax.com/">fexofenadine hydrochloride</a
[
url=https://allegrax.com/ ]allegra d coupons [/url] 
https://allegrax.com - fexofenadine 
<a href="https://fastcymbalta.com/">duloxetine 30mg</a
[
url=https://fastcymbalta.com/ ]duloxetine 30mg [/url] 
https://fastcymbalta.com - duloxetine
Answer Question

Your email address will not be published. Required fields are marked *

  • Minimum 20 character
ZK53

related questions

Most liked questions

Most answered questions

Login
ZK53 Refresh
Register
ZK53 Refresh
Forgot password
Ask a Question
Minimum 20 character
Minimum 20 character
Reply
Minimum 20 character
ZK53 Refresh