Questions tagged [escape-characters]

Escape sequences such as encodings of terminal commands and function keys

Filter by
Sorted by
Tagged with
2
votes
1answer
23 views

echo checkmark in shellscript (zsh) how-to

Why is this checkmark not printed correctly when executing my shellscript, even though echo alone outputs corrctly? script: #!/bin/sh YELLOW='\033[1;33m' NC='\033[0m' # no color echo "enter your ...
0
votes
0answers
17 views

rsync won't sync with at symbol (@) in path [duplicate]

I'm trying to rsync a folder on a remote server (Synology) to my server (TrueNAS), but the path has the at/email symbol (@) in it and I think rsync is throwing an error (below) because it's confused ...
0
votes
1answer
24 views

Why "$(findmnt | grep "\""proc"\"" | head -n 1)" is zero-length? (what is incorrect with escaping double quotes with `"\""` here?)

I'm surprised that: $ if [ -n "$(findmnt | grep "\""proc"\"" | head -n 1)" ]; then echo 1; else echo 2; fi 2 I've used "\"" before IIRC after ...
0
votes
1answer
23 views

Saving ANSI codes from dialog command into a file

Is it possible to get dialog command, example: dialog --title "HELLO" --yesno "Are you sure?" 6 30 into a file with all ANSI escape codes, so it can be printed later? You can ...
0
votes
1answer
52 views

Properly escaping asterisk/glob in (z)sh script

I have the following Problem, I need an environment variable that contains globbing characters as clear text, and I can't seem to escape them. Escaping with backslash works, but for some reason the ...
1
vote
1answer
125 views

Correct escaping of wildcard when using jq

The command below works: $ echo '{ "a": [ { "b": "1" }, { "b": "2" } ] }' | jq -r '.a[0].b' 1 But if I try to get the values of all the b elements ...
20
votes
2answers
1k views

How do you output a multi-line string that includes slashes and other special characters?

I would like to output this on completion of my bash script. /\_/\ ( o.o ) > ^ < I have tried the following but all return errors. echo /\\_/\\\n\( o.o \)\n > ^ < echo \/\\_\/\\\r\n( o....
1
vote
3answers
31 views

Pass special wildcards characters to set command

I would like to set variables with a special sign "*" using the "set" command $ Q='A * B' $ set -- $Q $ echo "$1 $2 $3" I expect "A * B" Of course, it does not ...
0
votes
3answers
39 views

Bash script: Avoid single quotes added to string

I'm trying to get an output of one function and pass it to other. set -x OUTPUT=$(git diff --name-only --diff-filter=AM develop... | sed 's/.*/"&"/') ./bin/phpcs $OUTPUT My main problem ...
0
votes
3answers
217 views

How can I find out what the escape codes my terminal are sending for certain special ones that cat will not show?

I wanted to find out what my terminal is sending for Ctrl+Backspace and Alt+Backspace, the standard way to do this is to run cat on the terminal and typing stuff usually works, but with certain output ...
1
vote
3answers
222 views

How do I escape semicolon in string with Bash

I got the JSON string below I use to feed to aws route53 change-resource-record-sets command to update a current DMARC record. As you can see the TXT value contains ;. JSON="{ \"Comment\&...
1
vote
0answers
39 views

Color escape codes showing up instead of colors in PS1 prompt [duplicate]

I'm trying to set up my prompt to conditionally display whether I am in a git repo, and if so, to display the branch. And I want it color coded, so I have it use some color escape sequences to make it ...
0
votes
1answer
64 views

Bash script escaping quotes

I'm writing a bash script to find all the images in the folder and find if they have corrupt endings with ImageMagick. This is the command I'm trying to automate: identify -verbose *.jpg 2>&1 | ...
1
vote
1answer
32 views

lesskey: add alt+right keybinding to less

I used cat -vte to see what escape codes my terminal emulator sends when I press alt+right: ❯ cat -vte ^[[1;3C Then I added this escape code to my lesskey file ~/.less: \e[1;3C forw-scroll Finally ...
1
vote
1answer
53 views

Escaping single quotes inside a single quoted sub-command, itself inside a double quoted command

The problem is simply as follow: watch "psql -d postgresql://user:pass@host:5432/dbname -c 'select id,name from table where name <> 'not available' order by id;'" this 'not available' ...
0
votes
0answers
24 views

Cursor and keyboard are acting strangely in

I am using kali linux and today all of a sudden my keyboard and cursor started acting weird. "^[[3~ keeps printing upon enter because of which im unable to work. My kali release is 2021.3. Also, ...
3
votes
0answers
50 views

Historical reason for function keys having non-consecutive key sequences in xterm

I'm using gnome-terminal as my terminal emulator, which sets TERM=xterm-256color. The key sequences sent when pressing the function keys F1, F2, … are as printed by $ infocmp -L1 | grep _f | sort -V ...
0
votes
0answers
37 views

I can't bind keys in ZSH / Where can I get escape sequence for the key in SHELL?

I try to bind Left / Right keys in ZSH, but it seems the escape sequences are wrong or terminal (but all of them? mate xterm, st) is blocking these \E sequences. I can bind for example Ctrl+Left, ...
0
votes
0answers
11 views

How to escape special characters in MATE Search Tool regex?

MATE Search Tool has an option "Contains the text" where text is always treated as a regex. The problem is I don't know how to escape special symbols there. For example, when searching for ...
0
votes
0answers
37 views

how to parse output ANSI code from script file (scriptreplay)

I'm trying to understand how script log file works So I can implement it in jQuery Terminal to play script files. I've found this JavaScript library. Didn't test it only looked at the code that is ...
0
votes
3answers
82 views

Assign sed command correctly

I am trying to assign the result of a sed command to a variable in bash, but I am unable to escape everything corrrectly (probably just due to my lack of knowledge in bash), I have tried: ...
0
votes
2answers
93 views

sshpass splitting the password as two strings seperated by the character "&" in password

I have a password variable PASS whose value is abc123&zxcv456 When I try to do SSH in jenkins using the password variable like below sshpass -p ${PASS} ssh -o StrictHostKeyChecking=no admin@100....
0
votes
1answer
80 views

Escape slashes when sending command output to an array [duplicate]

In my current project, I am trying to take the output from git branch -r to an array in zsh, as follows: % all_branches = ("${(@f)$(git branch -r)}") However, when I run this command, I get ...
2
votes
1answer
87 views

Is it possible to use the escape codes used in shell prompts elsewhere, such as with echo?

Example: When I run echo -e "\[\033[;33m\][\t \u (\#th) | \w]$\[\033[0m\]" the printed response is \[\][ \u (\#th) | \w]$\[\] where everything after the first \[ and before the last \] ...
1
vote
1answer
379 views

Stop systemd from flooding logs with "Ignoring unknown escape sequence"

This is my service [Unit] Description=Cleanup service I made [Service] ExecStart=/home/me/scripts/cleanup.sh -d /home/me/scripts/testfolder/ -f ".*/*.[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\{2\}-[...
1
vote
1answer
144 views

How to insert ESC control characters in a file in FreeBSD?

I want to enclose Fortran comments with two escape commands (ESC+E and ESC+F). This implies detecting the comment that begins with ! until end of line, and prefixing it with ESC+E and suffixing it ...
0
votes
0answers
32 views

Escaping characters and remote execution

I tried to use remotely via saltstack: cmd.shell "multipathd show maps format '%n;%w;%N' |awk -F';' '$3<4'" and receive an error: awk: cmd. line:1: <4 awk: cmd. line:1: ^ syntax ...
0
votes
1answer
26 views

URxvt not working properly with backslash characters \n and \t (given my particular ~/.bashrc configuration)

I have the following at the bottom of my ~/.bashrc which shows the last command run and the current working directory at the time of the last command in the title of my terminal window. trap 'echo -ne ...
0
votes
2answers
33 views

Pass qouted filename with spaces in a bash variable [duplicate]

In a bash shell, consider this: $ x="-name 'foo bar'" $ find $x find: paths must precede expression: `bar'' $ find -name 'foo bar' ./foo bar What can I put in $x to make find $x behave like ...
4
votes
4answers
2k views

Bash for loop with string var containing spaces

In my directory I have two files with space, foo bar and another file. I also have two files without space, file1 and file2. The following script works: for f in foo\ bar another\ file; do file "$...
1
vote
0answers
72 views

Make any program "think" its output is a terminal (ie stop it from "knowing" its output is a pipe/file/substitution/etc) to keep ansi-color-codes etc [duplicate]

EDIT: specifically what worked for me was using the python script in this answer and I gave the tweaks I used to get it working for my autoloading functions in fishshell, and on ubuntu 20.04, in this ...
1
vote
1answer
106 views

How can I disable kitty's paste from escaping?

If I have the string and copy that with CTRL+SHIFT+C https://test.invalid/?foo=bar()&baz=$quz{} And I paste that into the terminal I see the following, https://test.invalid/\?foo\=bar\(\)\&...
0
votes
1answer
98 views

Escaping UTF-8 encoded URLs

I want to replace a variable expansion with a URL --- directly inside a file. The URL I want to replace the variable expansion with is UTF-8 encoded due to the language of its webpage name being Right-...
-2
votes
1answer
214 views

Makefile using $() instead of `` backticks

How do I properly escape a the shell expansion syntax $() in a Makefile? .PHONY: test test: @if [ `find myDir -type f -not -name '*.openapi.yaml' | wc -l ` != 0 ]; then \ echo &...
2
votes
1answer
175 views

How to escape all of the special characters in order to be able to print the string as is?

I'm creating a tcsh script on the fly (with a static language). I have a <add-command-here> section that contains some command. I want to do: echo <add-command-here> In that <add-...
0
votes
2answers
575 views

Escaping quotes inside a quoted string

I'm trying to run curl to POST JSON data with x-www-form-urlencode inside a docker-compose file. For this example, I'm using this public website and I need to response to look like this # sh -c 'curl ...
0
votes
1answer
42 views

How to properly pack regex that contains both double as well as single quotes into a variable and evaluate it in Bash?

This stackoverflow question gives the following regex for RFC5322 compliant e-mail format matching: (?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0b\...
4
votes
3answers
1k views

What is the difference between a byte and a character (at least *nixwise)?

I understand that any character is comprised of one or more byte/s. If I am not mistaken, at least in *nix operating systems, a character will generally (or totally?) be comprised of only one byte. ...
0
votes
1answer
190 views

Asterisk * is not accepting in Case statement in bash

Asterisk is not accepting in my case statement, My case statement is below, i tried escaping with \ " ',but no luck. can you correct me where i am wrong here. case $tdat in *['\*''!'@#$%^&...
0
votes
1answer
33 views

How to know the end of an ANSI control code?

I'm working on code for a serial terminal and I'm implementing the ANSI escape codes for moving around the cursor, clearing the screen, etc, and I am curious how to know which to use since there doesn'...
1
vote
0answers
35 views

Escape slash in variable for awk pattern [duplicate]

I want to get all lines within specified date. The following pattern prints 15/Jan however when used for awk it gives Fatal Unmatched error. pattern=$(date -d "2 day ago" +'%d/%b') awk '$4 ~ ...
23
votes
3answers
2k views

What does the ^ character mean in sequences like ^X^I?

I was reading this message from the zsh mailing list about key bindings and I'd like to know which key I need to press: ^X^I (I think Ctrl-X Ctrl-I, the capital X and I) ^[^@ (I think Ctrl-Esc-@ ??) ^...
0
votes
1answer
44 views

Problematic [0;5;30m ANSI Code in ANSI Art

I have another question about ANSI Art. The problem is this file https://16colo.rs/pack/lgcy-003/hayn9-smaller.ans It have "à" character (the women in ANSI Art have it inside medalion on her ...
3
votes
1answer
220 views

Does urxvt support the OSC52 escape sequence?

The OSC52 escape sequence tells the terminal to put arbitrary text in the system clipboard. I want to use this fact to be able to copy to the local clipboard from a remote Vim session through ssh, as ...
0
votes
0answers
32 views

handling non-standard escape sequences on a hardware terminal

This is somewhat exotic. I'm writing a program that uses an old vt100 compatible terminal (minitel 1b) as the user interface. My program access the minitel directly through /dev/ttyUSB0. Following ...
3
votes
0answers
44 views

Capture colors with GNU screen hardcopy

Using GNU Screen (Screen version 4.06.02 (GNU) 23-Oct-17), I want to use hardcopy to save the colors of a specific screen. When I run screen -x nameofmyscreen -X hardcopy /tmp/hardcopy, the resulting ...
0
votes
0answers
42 views

Behavior of ANSI escape codes when mixing background and foreground [duplicate]

I'm investigating once more my ANSI escape rendering scripts and I've found weird behavior. The output color is defined by background or foreground by both mixed together. Example: echo -e "\x1b[...
1
vote
1answer
107 views

SHIFT+SPACE on terminal sends escape sequence

am using iTerm with Tmux, but I see this without tmux. If I hit SHIFT+SPACE I get the escape sequence ^[[32;2u. Is there a way to suppress it or disable that escape sequence? I am not seeing it in my ...
1
vote
0answers
58 views

What would cause deleting a character in vi to have garbled text appear on the screen?

I can't seem to figure out why this happens or even what to search for. Two videos demonstrating the issue: https://www.loom.com/share/7497428d757e45399faa5ebcf391e1be https://www.loom.com/share/...
0
votes
1answer
131 views

How to capture/ignore ESC during the execution of dialog?

Currently playing around with the dialog command and I have noticed that when I press Shift-Tab or press ESC, the execution immediately exits and I am back on the command prompt. Since this is not a ...

1
2 3 4 5
8