Questions tagged [escape-characters]

Escape sequences such as encodings of terminal commands and function keys

Filter by
Sorted by
Tagged with
3
votes
1answer
87 views

Escaping a '!' within double quotes

The bash manual entry for double quotes (https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html) states: If enabled, history expansion will be performed unless an ‘!’ appearing in ...
0
votes
1answer
30 views

Processing parameters with * passed to unix [duplicate]

I am receiving a query via a configuration file in unix, for ex. Config file content will be in the format: Table_name|query ABC|select ABC.A,ABC.B from PQR left join (select * from ABC) on ABC.pk=...
1
vote
2answers
26 views

Trouble passing Translations resource to -xrm because of newlines

It is possible to pass resources to X applications in command-line by appending them with -xrm parameters. So, if I want Xmessage background to be grey, I can issue xmessage Hi -xrm "xmessage*...
1
vote
1answer
39 views

Weird characters sent to ssh terminal when Alt+Tab between apps

I ssh to my AWS EC2 machine with Amazon Linux from local Ubuntu with GNOME Terminal. If open vim in the ssh session and then Alt+Tab from terminal to another app and then Alt+Tab back, annoying ...
2
votes
2answers
160 views

What ANSI escape 0x1b[0A and other 0 value codes should do?

I working on my ANSI formatting code for jQuery Terminal. It almost working but I have one issue it's related to 0A ansi code that should move cursor (also other 0 cursor codes: B C D E F) I've ...
0
votes
1answer
65 views

How can I send an escape sequence from a nested tmux session to iTerm2?

This works (puts the date and time in the clipboard) in just iTerm: printf "\e]1337;Copy=:$(date | base64)\a"; echo $(pbpaste) This works in tmux running locally (using the DCS passthrough): printf ...
2
votes
1answer
38 views

Why doesn't Esc-[ scroll left in `less`?

According to the manpage for lesskey, the following keys are bound to left-scroll and right-scroll: \e[ left-scroll \e] right-scroll \e( left-scroll \e) right-scroll \kl ...
-1
votes
2answers
46 views

Replace all backslash escape sequence-producable characters with their escaped escape sequences

EDIT: I'm very sorry, that I initially didn't make my requirements clear. I don't actually have access to the string written in a backslash-escaped way and have amended the example to make that ...
-1
votes
2answers
39 views

Stop executables and built-ins from interpreting a string argument starting with - as a switch? [duplicate]

Let's say I want to search a file for a string that begins with a dash, say "-something": grep "-something" filename.txt This throws an error, however, because grep and other executables, as well as ...
1
vote
0answers
30 views

xterm title bar: display path with spaces?

SOLUTION: There was a bug in the program. Instructions below with sleep helped me find it. Does anyone know how to do this? I tried the following, but the backslash escape before a space did not ...
1
vote
0answers
19 views

How to distinguish reply from the terminal from user input?

For example, in a program I want to get current cursor position on terminal (tput u7 or \E[6n on xterm): CSI P s n P s = 6 → Report Cursor Position (CPR) [row;column] as CSI r ; c R I write this ...
0
votes
2answers
61 views

Escape '/bin/bash' from filename

I am playing in a CTF and I want to create a file with name ;nc -e /bin/bash 127.0.0.1 443 using the command touch and I am failing. I can create a file named ;nc -e 127.0.0.1 443 without a problem ...
0
votes
1answer
72 views

how to escape quotes passed from command line to command in bash script

I'm using Debian 10. There is a command I run frequently to search for text. sudo grep -rin <path> -e <text to search for> Since I use this command often, I wanted to create a simple ...
0
votes
0answers
24 views

Change color in xterm via control sequence directly

This - I have to call it sleep mode session - I dumped from xterm: It started with this Why I can't send escape sequences from keyboard, but can do it from another tty? and Echoed escape ...
1
vote
1answer
318 views

Escaping single quotes in a bash script command

I am trying to write a script which has to execute a command containing single quotes in it. This is the command I am trying to execute in the script: srt-live-transmit udp://224.0.0.0:1234 'srt://@...
5
votes
2answers
417 views

bash: Replace single quote by two quotes in string

I have a variable, e.g. a'b, containing a single quote which I need to replace by two single quotes before writing it to a file: a''b. The following bash code used to get the job done for me ... ...
0
votes
0answers
39 views

Why are rapid Ctrl-Space sequences sometimes handled differently by GNU screen than slow Ctrl-Space?

I have GNU screen configured to use Ctrl+Space as the escape character. This means that Ctrl+SpaceSpace will send a literal Ctrl+Space to the process in the window. Also, Ctrl+Space Ctrl+Space is the ...
3
votes
3answers
2k views

What does `[$'\r\n']` mean?

I regularly use the expression line=${line//[$'\r\n']}. But what does [$'\r\n'] mean? I know it removes the '\r\n' characters but how does it do this? Does it remove the instances of both characters ...
0
votes
0answers
15 views

Cygwin Bash Escape Slash at First Place [duplicate]

Having this script.sh in Cygwin # !/bin/sh x="abc" echo "$x/" And running bash.exe script.sh, outputs: /bc instead of abc/ What is happening here?
0
votes
1answer
35 views

Do terminals ignore superfluous escape sequences silently?

Do terminals ignore superfluous escape sequences silently? #!/bin/sh printf "\033[?25l" printf "\033[?25l" # superfluous printf "\033[31m" printf "\033[31m" # superfluous printf "Red Text\n" ...
1
vote
2answers
777 views

Pass variable within json payload in shell script

In the following scenario, which is the way to pass ${MY_ENV_VAR} in the payload? I will have to escape: a) the single quotes of the payload b) the double quotes of the value of the text json ...
0
votes
2answers
57 views

Cannot escape '?' character in variables (unix)

I have been looking for this question everywhere, but I didn't find it and there doesn't seem to be any kind of answer yet to my current problem, which, frankly, doesn't even make sense. So, what I ...
0
votes
1answer
31 views

Why don't I see escape sequences in redirected stream OR how is color output implemented? [duplicate]

When running ls in terminal, output is variously colored: AFAIK this colorasing is accomplished by espace sequences (vt). But running ls | hexdump -cC shows only characters and LFs. Redirection to ...
0
votes
2answers
74 views

Sed escaping “.” and use $variable?

I don't understand this escaping. Is some generator available for it? i need replace normal text (185...) with Variable $NEW_DNS sed -i "185.228.168.168,185.228.169.168|$NEW_DNS /etc/wireguard/wg0....
4
votes
3answers
5k views

Using `printf` to print variable containing `%` percent sign results in “bash: printf: `p': invalid format character”

I want to use printf to print a variable. It might be possible that this variable contains a % percent sign. Minimal example: $ TEST="contains % percent" $ echo "${TEST}" contains % percent $ printf ...
0
votes
2answers
245 views

Complex mouse inputs in XTerm

From the Xterm Control Sequences doc: Normal tracking mode sends an escape sequence on both button press and release.  Modifier key (shift, ctrl, meta) information is also sent.  It is enabled ...
2
votes
1answer
81 views

What does the leading part of Bash's default PS1 in Ubuntu mean?

This is the $PS1 of my Bash shell on a freshly installed Ubuntu 18.04: \[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \$ I can ...
-1
votes
2answers
101 views

How to make code interpret $ but not *? [closed]

I have some perl code (don't focus on what it does right now, i'm still working on it): #!/usr/bin/perl -w if(!@ARGV) { print ("ERROR: NO ARGS\n"); exit 1; } else { use Cwd qw(cwd); my $dir ...
0
votes
2answers
282 views

Using printf with escape sequences?

I can change my cursor shape like this: printf "\x1b[\x31 q" # block :) printf "\x1b[\x35 q" # ibeam :) But when I assign that to a variable with %s and expand using printf, it doesn't work: CURSOR=...
1
vote
2answers
79 views

Escaping spaces in dash [duplicate]

I want to do something like this. $ touch a\ b $ cmd=cat\ a\ b $ echo $cmd cat a b $cmd cat: a: No such file or directory cat: b: No such file or directory There are problems with the spaces in the ...
0
votes
1answer
124 views

printf and echo -e are giving different results

I am using \0n escape sequence with echo -e and printf where n is the octal value of the ASCII character to be printed. When i used the statement echo -e "\0101" the shell is printing character A but ...
1
vote
2answers
729 views

How to key bind 'backward-kill-line' to Ctrl+Shift+Backspace?

I have used answer of zsh kill Ctrl + Backspace, Ctrl + Delete to configure following key binding: Ctrl+Backspace: delete until the beginning of current word, Ctrl+Delete: delete until the end of ...
6
votes
1answer
281 views

Escape a mm/dd/YY backup date in a file name

I have been trying to: cp file.csv file.$(date +%D).csv But it fails because the filenames is: file.03/27/19.csv with the slash of separate directories. And I have been trying again to: cp file....
1
vote
1answer
251 views

Convert JSON with raw characters in string

Had a problem with a tool that was generating illegal JSON. Some of the JSON strings contained characters in the range 00-1f. So I wanted to convert these characters to correctly escaped valued \...
1
vote
2answers
61 views

Escape dots and asterisks in command line variable output string

I have a command that sets an environment variable from a command like this: BLACKLIST=$(python tools.py gen-blacklist) Which results in a string that contains dots * and asterisks *, like this: ...
0
votes
0answers
305 views

Escaping a string for a parameter inside a script [duplicate]

I have a shell script inside of which I call a command with several arguments. When I call the command from the terminal, the proper syntax is: command --foo='bar baz' Inside my script, I want to ...
0
votes
0answers
22 views

I am using Ubuntu and trying to minimize putty window from a bash script, are there any parameters or escape sequences?

For instance in order to maximize putty from command line someone stated (in this thread) that the escape sequence is '\e[9;1t' I wondering is there any sequence to minimize putty window? where can ...
-1
votes
1answer
855 views

How to send ^D / EOT character to stdin of a shell process?

Suppose I have two shells open, one with PID 1234 and the other - 5678. I can clear the screen and reset of the other shell via echo $'\033c' > /proc/1234/fd/0 as if reset was typed on the prompt ...
0
votes
1answer
42 views

ANSI C quoting for tab and newline sometimes does not work

I am trying to use a newline in bash. I found that I need ANSI C quoting for that (i.e. $'\n'), but this often does not work for me. So I am wondering what I am doing wrong. # This works >> ...
1
vote
0answers
124 views

Using a here-doc with trailing backslashes inside a process substitution in bash

This: cat <<EOF one two three EOF Prints: one two three And this: cat <<EOF one \\ two \\ three EOF Prints: one \ two \ three But while this: cat <( cat <<EOF one two ...
3
votes
1answer
323 views

BASH question: using read, can I capture a single char OR arrow key (on keyup)

So here's my deal: working in BASH, I have already built out a function which works just fine that accepts an array or any number of parameters, and spits out an interactive menu, navigable by arrows ...
1
vote
2answers
97 views

How do I use shell commands with a directory that contains '-' like '-78059735'? [duplicate]

I have an external program that generates directories with strings that are negative integers. I am trying to use basic shell commands including cd and ls with this directory, for example: cd -...
1
vote
1answer
564 views

Stringify bash command from array of arguments for use in “bash -c”

I would like to stringify a given command, given as an array. This would be useful to for example put a command inside a bash -c. For example : cmd=( "printf '%s\n'" "foo bar" "baz bang" ) ...
0
votes
2answers
75 views

what is wrong with sed while using words starting with “w”

This works echo " HELLO x=10" |sed 's/ *\HELLO \+/HELLO /g' removes continuous space before hello and after word "HELLO" but this doesn't echo " WHERE x=10" |sed 's/ *\WHERE \...
2
votes
1answer
389 views

Escape keywords with tmux send

Using tmux to send commands along from one terminal to another, I realize that $ tmux send -t mySession "text" ENTER correctly sends text, but $ tmux send -t mySession "up" ENTER sends text again, ...
-1
votes
3answers
2k views

Find: No such file or directory

Why does $ while true ; do 'date; time find /tmp/test -type f \ -exec cp /dev/null {} \;';sleep 3600; done not work and instead return an error message: -bash: date; time find /tmp/test -type f -...
0
votes
2answers
2k views

Passing an argument with double and single quotes to another call in bash [closed]

I have a call ./run.sh name --vars="service_name='someothername'" and I'm trying to call another program with exactly same --vars="service_name='someothername'" argument from run.sh, however when ...
1
vote
1answer
127 views

ANSI escape sequence ^[[K processed by less -R but not most

I'm writing a wrapper around ack to search for code locally with some additional lines of context piped to a pager. Here's the wrapper script ackc. Between the different examples, I'll be varying ...
0
votes
1answer
867 views

Correctly Escape echo -ne [closed]

I'm outputting an echo -ne command to a file in my set-up script for a usb mouse HID. Here is the script, which is run as root through /etc/rc.local at bootup: #accidentally had a newline here <...
0
votes
1answer
1k views

What is this sequence of control characters (M-bM-^TM-^@) (dashes)? How can I transform these? [closed]

I have a 'typescript' file that if i cat -v I get the following within the output: M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-^TM-^@M-bM-...

1 2 3 4 5 7