How can I use aliased commands with xargs?

Aliases are shell-specific – in this case, most likely bash-specific. To execute an alias, you need to execute bash, but aliases are only loaded for interactive shells (more precisely, .bashrc will only be read for an interactive shell). bash -i runs an interactive shell (and sources .bashrc). bash -c cmd runs cmd. Put them together: … Read more

Generate a random filename in unix shell

Assuming you are on a linux, the following should work: cat /dev/urandom | tr -cd ‘a-f0-9’ | head -c 32 This is only pseudo-random if your system runs low on entropy, but is (on linux) guaranteed to terminate. If you require genuinely random data, cat /dev/random instead of /dev/urandom. This change will make your code … Read more

Check if a file is executable

Take a look at the various test operators (this is for the test command itself, but the built-in BASH and TCSH tests are more or less the same). You’ll notice that -x FILE says FILE exists and execute (or search) permission is granted. BASH, Bourne, Ksh, Zsh Script if [[ -x “$file” ]] then echo … Read more

Can a shell script set environment variables of the calling shell? [duplicate]

Use the “dot space script” calling syntax. For example, here’s how to do it using the full path to a script: . /path/to/set_env_vars.sh And here’s how to do it if you’re in the same directory as the script: . set_env_vars.sh These execute the script under the current shell instead of loading another one (which is … Read more

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