All Questions
Tagged with bash-script or shell-script
16,787 questions
0 votes
0 answers
49 views
how to convert hex memory dump to Docsis config file?
Hex memory dump is Docsis config file. Is it possible to convert this hex dump info valid Docsis config file? Preferably, using Perl and DOCSIS::ConfigFile module. (or Python scripts, python-docsis). ...
2 votes
1 answer
197 views
Replacing the domain string in the compiled binary file with an IP address
Just in theory: is it possible to replace the domain string in the compiled binary file with an IP address by editing a binary file in place with sed? (IP address belongs to a different domain, but ...
11 votes
1 answer
1k views
Is there any difference between [[ -n $1 ]] and [[ $1 ]] in bash?
The test [[ -n $1 ]] yields True if the length of string is non-zero. But I've seen elsewhere and have tried using just [[ $1 ]] without the primary -n and it seems to have the same effect. Is there ...
2 votes
1 answer
95 views
Bash: function in a script with flags
Using https://stackoverflow.com/a/7948533/31298396, we can implement flags for a script testing as follows: #!/bin/bash # Flags # Source: https://stackoverflow.com/a/7948533/31298396 TEMP=$(getopt ...
5 votes
1 answer
343 views
zsh - if condition comparison: '-ne' and '!=' have different result
Why these commands lead to opposite comparison results between -ne and !=? Seems != works but -ne does not? I thought they are the same while comparing strings. % set -o | grep pipe pipefail ...
0 votes
1 answer
64 views
Bash Script Linux - combines a QUIET function with other functions without hiding some of them
#!/bin/bash DefaultColor="\033[0m" GREEN="\033[32m" RED="\033[31m" PURPLE="\033[35m" YELLOW="\033[33m" CYAN="\033[36m" CmdOk="\033[...
5 votes
1 answer
373 views
locking scripts using flock - can same file descriptor be used concurrently?
Common method for preventing concurrent runs for a given script is utilizing flock as: LOCK=/var/lock/my-lock exec 9>>"$LOCK" if ! flock --exclusive --nonblock 9; then echo "...
1 vote
1 answer
57 views
Docker Container Mount Name, Type and other values
I am writing a bash script and I am aware that I can get information of the mounts attached to a container using docker inspect --format '{{.Mounts}}' <container-name> which gives a result such ...