Most of the things I run in the terminal take a long time to compute and I would like to have bash output a time report at the end of every command entered into the terminal. Is there something I can put into my bashrc to do this?  Example:  $ find / -ls &lt;find / -ls return info&gt; start time = 10:21:54 | end time = 10:31:34 | time lapsed = 00:10:20 $   or  $ make all &lt;make all return info&gt; start time = 10:21:54 | end time = 10:31:34 | time lapsed = 00:10:20   It would be nice to be able to add a list of exceptions for commands like cd, but it wouldn't really bother me.
108737
Is it possible to forcibly add a timing alias (for lack of a better way to phrase it) to every command in bash? For example, I would like to have a specific user who, whenever a command is run, it is always wrapped either with date before and after, or time. Is this possible, and, if so, how?
44884
The time(1) command allows you to time any command, by passing it as arguments to time.  I know it's possible to redirect stderr and stdout to a file via 2&gt;&amp;1, and there's also tee(1) which allows one to copy its input to both the screen and a file.  However, I do not know how to add timestamps to logs.   Is there a tool to redirect stderr and stdout to a file, AND append timestamps to it for logging purposes?
99088
How might I go about limiting the execution time of a command line program in windows? I know in linux there is timeout/timelimit available, but I have been unable to find similar utilities for windows.
113004
I am looking for a way to store lock/unlock screen times.  A=$(date) echo $A &gt;&gt; $HOME/time_xprofile   What did I try:  $HOME/.bashrc $HOME/.bash_logout $HOME/.bash_prompt $HOME/.xprofile   Then I locked the screen and checked whether file appeared and it failes every time. How can I check the time than?
114602
When running time consuming processes in terminal, I like to add something like say "done" as an additional command so that I can get alerted when the current process ends. For example:  $ do_this_long_thing; say "done";   Works great. But sometimes I forget the say "done" command, only to realize it once the long command is already running. Is there a way to add that additional command to the queue once a command is already running?
45722
I want know how I can run a command for a specified time say, one minute and if it doesn't complete execution then I should be able to stop it.
46255
I have a command that I run in a folder that outputs MD5 hashes and filenames on the terminal:  ls |sort -nr | xargs md5sum   I need this output in a text file that I can download and compare to another folder on another customer's machine. How can I modify the command such that its output is stored in a file in say /tmp? I'm using Redhat 5.
117426
Why when I try to write a function just in one line into .bashrc file,  list(){ ls -a }   I get error?  bash: /home/username/.bashrc: line num: syntax error: unexpected end of file   but when I write it in multi line it's ok?  list(){     ls -a }
30693
I often find myself in the following position: I've started typing a long command at the bash prompt, but half-way through I find out I need to check something with another command. This is a problem when I'm at the console (no X), which is often the case, because then I only have the following unsatisfactory ways to do it, that I know of:    Hit ctrl+alt+F2 and log in on another virtual console, and find out what I wanted, then go back and continue  ctrl+a, type echo + space + enter, find out what I wanted, press ↑ until I find my command, ctrl+a, del x 5, ctrl+e, and continue  Highlight what I've typed so far with my mouse (if gpm is running, which it usually is), press ctrl+c to interrupt, find out what I wanted while being careful not to use my mouse to highlight stuff, then press middle mouse button on a new prompt and continue  Pray to the command line gods that the half-written command will have no adverse effects but simply fail, and gingerly press enter, then find out what I wanted, press uparrow until I get my command back, and continue  Jump into my time machine, travel back in time and remind myself to start screen before starting to type command, travel back to the present, press ctrl+a c, find out what I wanted, press ctrl+a ctrl+a, and continue   So what I want to know is, is there some more elegant way of doing this? A sort of subshell-command or similar?  I'm most interested in methods that do not require any preparations or setup to work.
50155
In the Bash Reference Manual,      The use of time as a reserved word permits the timing of shell builtins, shell functions, and pipelines. An external       time command cannot time these easily.    Could you explain why the quote says that?  Is this because of the difference between a reserved word and a command, not just limited to the case of time? For example, how does the bash shell parse or interpret them differently?   Or is this only limited to the case of time? In the following examples,   why does the external time work on a shell builtin, and a pipeline, while the quote say it "cannot time these easily"?  External time on a shell builtin:  $ /usr/bin/time echo hello hello 0.00user 0.00system 0:00.00elapsed 0%CPU (0avgtext+0avgdata 1676maxresident)k 0inputs+0outputs (0major+78minor)pagefaults 0swaps   External time on a pipeline:  $ /usr/bin/time sleep 10 | sleep 5 0.00user 0.00system 0:10.00elapsed 0%CPU (0avgtext+0avgdata 1776maxresident)k 0inputs+0outputs (0major+79minor)pagefaults 0swaps  In the following example, why does the external time on a shell function fail? What does its error output mean?  $ function mytest () { sleep 10; }  $ /usr/bin/time mytest /usr/bin/time: cannot run mytest: No such file or directory Command exited with non-zero status 127 0.00user 0.00system 0:00.03elapsed 0%CPU (0avgtext+0avgdata 1252maxresident)k 32inputs+0outputs (0major+30minor)pagefaults 0swaps  It seems that the quote does not just apply to timing shell builtins, shell functions, and pipelines, :  $ time { echo hello; sleep 3; echo tim; } hello tim  real    0m3.002s user    0m0.000s sys 0m0.000s   $ /usr/bin/time { echo hello; sleep 3; echo tim; } bash: syntax error near unexpected token `}'   Why does the shell say "bash: syntax error near unexpected token }" in the case for command /usr/bin/time?
100741
I am making a bash script for my own use. How can I run a command for a certain time (like 20 seconds) and then terminate it? I have tried a lot of solutions but nothing works. I also tried the timeout command with no success. Please give me some solution for this. For example: I want to run this command in a script and terminate it after 10 seconds some command
122179
When I need to find my recently used files, this command:  ls -lt  lists in ascending order (by time), when there are lots files, I need to scroll to the top to see needed files, because won't fit in terminal screen.  After finding out that tac inverses the output, I use: ls -lt dir/ | tac Is there more fun way of doing it, without using external scripts/utils?
16488
Currently I have a shell script which logs messages to a log file like this:  log_file="/some/dir/log_file.log" echo "some text" &gt;&gt; $log_file do_some_command echo "more text" &gt;&gt; $log_file do_other_command   When executing this script, there is no output to screen, and, since I'm connecting to the server via putty, I have to open another connection and do "tail -f log_file_path.log", because I can't terminate the running script and I want to see the output in real time.  Obviously, what I want is that the text messages are printed on screen and into file, but I'd like to do it in one line, not two lines, one of which has no redirection to file.  How to achieve this?
50840
I want to do such as following:  #!/bin/bash command1 pause 30 seconds command2 exit   This is only example script with pause of 30 seconds between run of 2 command.  How to do this?
83016
I have a bunch of image files spared into different folders with a false timestamp on the filename (1 hour delay) and i want to correct that according to the creation time.   I am now trying to write a **shell script** that can go through all the folders > extract the creation time and and replace it on the filename timestamp, below a small example:   Original filename with false timestamp:  Filename, Created Date, Modified Date 20180524010500530_FR785101.jpg, 2018-05-24 00:05:00, 2018-05-24 00:05:34  The output would be:  Filename, Created Date, Modified Date 20180524000500530_FR785101.jpg, 2018-05-24 00:05:00, 2018-05-24 00:05:34  Can Anyone tell me if that is possible with a shell script ? Then, can anyone give me some direction on how to use the ls command or any other command that can do the job ?  I have started to document myself on the use of the ls command but i still cannot figure out how i can extract the creation time and replace it into the filename timestamp, also i don't know how i can make the script run through all the folders and sub-folders containing the image files,
2458
I want to create a text file which will add each command I am going to run on the terminal as a new line entry in the text file. i.e., I need to keep a record of what are the things I'm doing in the terminal. Further if I can keep a record of outputs I'm getting in the terminal, along with the inputs in the terminal, as a text file, it will be much better.   Each time I forget a command I have to search again in the Internet for the command.  Can I can make a file like above?
114750
I'm searching for the possibility to execute a shell script or command based on idle time in the bash shell.  As an example, if I'm in a SSH session to a server of mine and after X minutes of inactivity in the terminal, I want a command to start a desired program like cmatrix, and when I come back and press a key I will get back where I left.