Linux command to get time in milliseconds

date +”%T.%N” returns the current time with nanoseconds. 06:46:41.431857000 date +”%T.%6N” returns the current time with nanoseconds rounded to the first 6 digits, which is microseconds. 06:47:07.183172 date +”%T.%3N” returns the current time with nanoseconds rounded to the first 3 digits, which is milliseconds. 06:47:42.773 In general, every field of the date command’s format can … Read more

how to smart append LD_LIBRARY_PATH in shell when nounset

You could use this construct: export LD_LIBRARY_PATH=/mypath${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} Explanation: If LD_LIBRARY_PATH is not set, then ${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} expands to nothing without evaluating $LD_LIBRARY_PATH, thus the result is equivalent to export LD_LIBRARY_PATH=/mypath and no error is raised. If LD_LIBRARY_PATH is already set, then ${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH} expands to :$LD_LIBRARY_PATH, thus the result is equivalent to export LD_LIBRARY_PATH=/mypath:$LD_LIBRARY_PATH. See the Bash … Read more

How to make a text blink in shell script

Try adding -e if it’s not working without it You may need to add the -e option to echo (at least that’s required on all or most systems I use). The following will tell your system to blink the text: echo -e “\033[5mTitle of the Program\033[0m” You can have blinking and color And you don’t … Read more

Invoking program when a bash function has the same name

You can use the command built-in to suppress shell function lookups. command: command [-pVv] command [arg …] Execute a simple command or display information about commands. Runs COMMAND with ARGS suppressing shell function lookup, or display information about the specified COMMANDs. Can be used to invoke commands on disk when a function with the same … Read more

The difference between $* and $@ [duplicate]

Unquoted, there is no difference — they’re expanded to all the arguments and they’re split accordingly. The difference comes when quoting. “$@” expands to properly quoted arguments and “$*” makes all arguments into a single argument. Take this for example: #!/bin/bash function print_args_at { printf “%s\n” “$@” } function print_args_star { printf “%s\n” “$*” } … Read more

When to use set -e

Yes, you should always use it. People make fun of Visual Basic all the time, saying it’s not a real programming language, partly because of its “On Error Resume Next” statement. Yet that is the default in shell! set -e should have been the default. The potential for disaster is just too high. In places … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)