12

Probably easiest to use tr to convert the zeroes from /dev/zero to whatever you want, and then cut to length using dd or head or such. This would write 18520 bytes with all bits ones, so value 0xff or 255, or 377 in octal as the input must be: < /dev/zero tr '\000' '\377' | head -c 18520 > test.bin (To convert from hex or decimal to octal, you could ...


11

Don't use dd bs=…: it isn't reliable. Either use ibs=1 obs=1 or use less error-prone tools. Most head implementations can count bytes: </dev/zero head -c 18520 If you want a file filled with a single byte other than zero, change the byte value with tr. For all-bits-one: </dev/zero head -c 18520 | tr '\0' '\377'


10

The shell's arithmetic doesn't support chained comparisons like that. Instead, the first a < b returns either 1 or 0, depending on if the relation is true or not. So, if k is 0, then ((0 < k < 1)) is ((0 < 0 < 1)), the same as (( (0 < 0) < 1)) because of left-association. Zero is not less than zero, so 0 < 0 is falsy, so in an ...


7

For whatever reason, it is obfuscated in two layers. The first script creates a second similar script that it runs with eval. The second script creates a third script that it evals. This is the start of the third and final script (indented by me for readability): pkg install pulseaudio dir=$(pwd) if grep -q "anonymous" ~/../usr/etc/pulse/default....


5

This seems to match the description of -e/-errexit in the bash documentation: The shell does not exit if the command that fails is part of the command list immediately following a while or until keyword, part of the test in an if statement, part of any command executed in a && or || list except the command following the final && or ||, any ...


4

exec script.sh replaces the current shell with the one defined in the shebang line of script.sh, and uses that interpreter to run the rest of the file. This could be anything from /bin/sh to /usr/bin/python, no matter what the filename extension is. To do this, script.sh has to be executable. One of the side effects of this is that when script.sh is done the ...


4

From the manual [emphasis mine]: errexit Same as -e. -e Exit immediately if a pipeline […], which may consist of a single simple command […], a list […], or a compound command […] returns a non-zero status. The shell does not exit if the command that fails is part of […] any command executed in a && or || list except the command following the final ...


2

Even though it's HTML and not proper XML you can actually do this with xmlstarlet. Let's call your file index.html. Command invocation: xmlstarlet fo -H index.html 2>/dev/null | xmlstarlet sel -t -v '//a[@title="view quote" and string-length(text()) > 1]' -n 2>/dev/null Output: Everything in life is luck. The first thing the secretary ...


2

Use lsb_release -s -r or lsb_release --short --release This gives you the release number without the Release: heading.


1

If you want the output saved to a file called "output" on the local host: scp -p ./localscript remotehost: ssh -q remotehost <<'EOF' > output ./localscript --include Yes | awk -vhostname=$(hostname) '{print hostname, $0}' EOF The -q option for ssh is used to suppress the warning message saying "Pseudo-terminal will not be ...


1

to answer your question specifically, using dd will work great with tr in a pipe dd if=/dev/zero bs=18520 count=1 | tr '\000' '1' > test.bin however, you should clarify the scope of this in order for one to give you a more relevant answer


1

$ awk -F'[,=]' -v OFS=',' '/^dn/{dn=$2} /^me/{print $2, dn}' file aaa,333-MMMM-PPPP_DET1 bbb,333-MMMM-PPPP_DET1 ccc,333-MMMM-PPPP_DET1 ddd,333-MMMM-PPPP_DET1 eee,333-MMMM-PPPP_DET1 aaa,333-MMMM-PPPP_DET3 ggg,333-MMMM-PPPP_DET3


1

You have to know how to pass arrays into a function. The method you are currently using is not doing what you think it is. $4 would equal tma instead try declaring by using local -n and settings a variable with a DIFFERENT name than the variables that will be passed to the function. I believe this will apply as long as you are using a version of bash4.3 or ...


1

As you already use bash, use an array. files=() while IFS=$'\n' read -r line; do files+=( "$line" ) done file "${files[@]}" You can also look at xargs, with a delimiter of newline the behavior should be similar.


1

Your echo "${FUNCNAME[1]}" prints to stdout, so its output belongs to the output of the debug_function, which in turn belongs to the output of the test_function. Print the message to stderr: by redirecting the output of echo: echo "${FUNCNAME[1]}" >&2 or by redirecting the entire output of debug_function (if the whole function ...


Only top voted, non community-wiki answers of a minimum length are eligible