Adding seconds to string date in bash [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
Improve this question
I have a variable string date like this
#!/bin/bash
timeString="Mar 15 09:27:26"
I want to add 10 second to this variable and I do not know how.
It might be a duplicate post, but I did not had the inspiration to find a simple answer.

Convert to seconds, add 10, convert back to date string:
date +"%a %d %H:%M:%S" --date=#$(($(date +%s --date="Mar 15 09:27:26") + 10))
Uses $((...)) arithmetic substitution and $(...) command substitution of bash, and format converting functions of GNU date. (Note: On Mac, date has a different format)

Related

Script in Linux to create user and password (validating certain characters) [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 days ago.
Improve this question
good afternoon. I'm trying to write a script that allows me to create an user and password. Specifically, 8 characters, at least 2 numbers, at least 2 letters and at least one of these symbols: #, +, -, %, *.
The script must be a .sh file, starting with #!/usr/bin/bash
Suggestions? Of course, I compile with chmod +x and run with ./ . Please help. Thanks.

Is there a way to format a bash file to become a one liner? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 10 months ago.
The community reviewed whether to reopen this question 10 months ago and left it closed:
Original close reason(s) were not resolved
Improve this question
I have a bash file that is pretty long, and I don't want to spend hours painstakingly going through and making it a one liner. Is there some online tool or command I can use to make my file into a one liner?
I already tried looking for beautifiers and formatters, but none do what I need it to, and I even searched on here for about an hour and all I could find was stuff about how to make a one liner not how to convert my entire file into a one liner.
This is a horrible idea. Do not do it.
That said, if you define the following function:
onelineify() {
script_content=$(gzip -9 <"$1" | base64 -w0)
printf '%s\n' '#!/usr/bin/env bash'
printf 'eval "$(base64 -d <<<%q | gunzip -c)"\n' "$script_content"
}
onelineify yourscript will write a version of your script that is only one line (beyond the shebang) to stdout.

What is the function of {:-9} in python? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
In the Python tutorial (https://docs.python.org/3.8/tutorial/inputoutput.html) they used {:-9}, and i cant figure out for the life of me what the -9 does?:
yes_votes = 42_572_654
no_votes = 43_132_495
percentage = yes_votes / (yes_votes + no_votes)
'{:-9} YES votes {:2.2%}'.format(yes_votes, percentage)
Output:
42572654 YES votes 49.67%
The :-9 value indicates padding. If you remove the - the effect will be the same.
However, according to the docs, the - indicates that a sign should be used only for negative numbers (this is the default behavior).
Example:
Replacing %+f, %-f, and % f and specifying a sign:
>>> '{:+f}; {:+f}'.format(3.14, -3.14) # show it always
'+3.140000; -3.140000'
>>> '{: f}; {: f}'.format(3.14, -3.14) # show a space for positive numbers
' 3.140000; -3.140000'
>>> '{:-f}; {:-f}'.format(3.14, -3.14) # show only the minus -- same as '{:f}; {:f}'
'3.140000; -3.140000'
More on Python's Format Specification Mini-Language can be found here

Shell time command source code? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
Where can I find the time bash utility source code? Is there a website that allows to search for this code?
The time command is from the GNU project, so all of the source code is available there.
Specifically, you are probably looking for this: http://ftpmirror.gnu.org/time/
The time command in Bash is built-in, so it should be found in the GNU Bash source code.

Cron syntax interpreter? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Does anyone know of a tool that will given a cron string for example * * * 1 * * tell you what that string translates to?
I know it's not rocket science but I want to be sure that I'm constructing the correct interval for a scheduled task.
Just found this, was exactly what I was looking for and it seems like what you want too: http://cronchecker.net/
I just found that this web app is more able to process cron expr:
http://crontranslator.appspot.com/
I found this other one that let you build you cron expr from a form, and that can be handy too:
http://www.cronmaker.com/

Resources