Questions about shell scripts, executable files that are interpreted by a shell (bash, zsh, etc.).
Shell scripting is often considered a simple domain-specific programming language. Typical operations performed by shell scripts include file manipulation, program execution, and printing text.
I want to write logic in shell script which will retry it to run again after 15 sec upto 5 times based on "status code=FAIL" if it fails due to some issue.
I have a shell script where we have following lines if [ -z "$xyz" ] and if [ -n "$abc" ], but I am not sure what their purpose is. Can anyone please explain?
I'm attempting to write a script that will be run in a given directory with many single level sub directories. The script will cd into each of the sub directories, execute a command on the files in the directory, and cd out to continue onto the next…
#! /bin/sh -
Is (or at least was) often the recommended shebang to have a script interpreted by /bin/sh (or #! /bin/bash - for bash, #! /bin/ksh - for ksh, etc).
Why not just #! /bin/sh or #!/bin/sh?
What's that - for?
I was reading about positional parameters in Unix and then I found this info:
The shell allows a command line to contain at least 128 arguments;
however, a shell program is restricted to referencing only nine
positional parameters, $1 through $9,…
I have a CRONTAB entry as below. Can someone tell me what the below statement is exactly doing?
1 0 * * * /vol01/sites/provisioning/MNMS/45627/45627.sh1 >> /vol01/sites/provisioning/MNMS/45627/output/cron.log 2>&1
If I have a string that looks like this:
"this_is_the_string"
Inside a bash script, I would like to convert it to PascalCase, ie UpperCamelCase to look like this:
"ThisIsTheString"
I found that converting to lowerCamelCase can be done like…
I have a requirement, if I execute a script ./123 with an arguments of empty path, say /usr/share/linux-headers-3.16.0-34-generic/.tmp_versions(this directory is empty). It should display "directory is empty"
My code is:
#!/bin/bash
dir="$1"
if […
Found this in an obfuscated malicious shell script, beginning with:
${!#}${*^} <<<...
Could not find any reference to ${!#}, but when echo'd, it outputs -bash. Is this a secret referene to the running shell? Why there is an extra dash then?
Thanks!
Why are shell scripts are so hard to develop? In NodeJS I could simply do:
require('./script')
and it will always require script relative to the current script. But if I try that in shell/bash:
./script.sh
it will look for script relative to cwd…
I am working on a script that will copy ONLY files that have been created within the last day off to another folder. The issue I am having is the script I have copies all of the files in the source directory instead of just the files less than a…
How do I get the previous month end date, based on processing date?
Examples:
Processing date = 15jan2015
Expected date = 31dec2014,
Processing date = 10feb2015
Expected date = 31jan2015
Let's say I have a script that will be executed on various machines with root privileges, but I want to execute certain commands within that script without root.
Is that possible?