Tag Info

New answers tagged

0

Missed a space: PB_ACL="acl="`echo $IMGREQ | jq -r '.data.acl'` ^


1

Use od, hexdump, xxd, or similar to print binary data in human-readable form. For example: $ tput setaf 1 | od -c 0000000 033 [ 3 1 m 0000005


3

Sounds like you want the opposite of printing them literally, you want those escape characters converted to a printable descriptive form like \E or \033, ^[... If it's just the ESC (0x1b) character you want to convert to \E, then with ksh93, zsh or bash (typically, the same ones that also support that non-standard %q), you can do: printf '%s\n' ...


0

You can use printf directly, eg printf "\033[31mfail"


2

This has nothing to do with bash, it is purely an effect of the terminal's behavior, specifically scroll. When you reach the bottom of the screen, and start to type on the next line, the terminal creates a new blank line by pushing everything up one line. (In older terminals this destroys the top line. In newer terminals the top line is just pushed into the ...


3

execcmd="convert -monitor ${filearray[@]} output.pdf" But executing that with $execcmd convert is throwing numerous errors at me Don't call $execcmd, as it has already lost the differentiation between filenames and space-separated parts of filenames. Instead, execute the command itself with quoted arguments: convert -monitor "${filearray[@]}" ...


2

You can use the other expression for backquotes $(cmd), that can be nested. On the other hand, you can produce inner arguments to backquotes into variables and use them inside echo $(echo `date`) echo $(echo $(date)) x=`date` echo `echo $x` Without the escape quote \`, you will have echo $(echo )date$( ) The shell will try to parse the arguments, so ...


1

If you want to stick with portability, you can't use echo or printf, both treat escape sequences \xXX unspecified as POSIX defined. Even in GNU system, the behavior of echo, either builtin or /bin/echo can be alter. You can try: $ POSIXLY_CORRECT=1 /bin/echo -en '\x61' -en \x61 $ env BASHOPTS=xpg_echo POSIXLY_CORRECT=1 bash -c "echo -en '\x61'" -en a ...


1

In bash, echo is a builtin function, so you are getting that behavior. In sh it is not a builtin. Looks like sh uses its builtin "echo" command which is different. So try using /bin/echo rather than without the /bin/.


0

Use heredoc for such an input. And you need to escape newlines and quotes because they are not allowed in your appliaction/json construct. user_data=$(awk -v 'ORS=\\n' 1 <<'HERE' | sed 's/"/\\"/g' #cloud-config users: - name: SomeUser groups: wheel shell: /bin/bash ssh-authorized-keys: - ssh-dss AAAABBBBCCCCDDDDD... runcmd: - sed -i -e ...


0

You are using the single quotes for for the -d commandline options both for specifying strings separated by $variable as well as for quoting the argument for the second sed command. For $aAllowUsers SomeUser this might be what you want, but for /PermitRootLogin/s/^.*$/PermitRootLogin no/ this is probably not what you want /bin/sh to expand. Putting ...


2

Only \033 is an escape and it initiates the escape sequence up until and include the ;. \033]0;. This initiates a string that sets the title in the titlebar of the terminal and that string is terminated by the \007 special character. See man console_codes: It accepts ESC ] (OSC) for the setting of certain resources. In addi‐ tion to the ECMA-48 ...



Top 50 recent answers are included