Questions tagged [escape-characters]

Escape sequences such as encodings of terminal commands and function keys

Filter by
Sorted by
Tagged with
0 votes
0 answers
12 views

zsh command expansion applies esacping [duplicate]

I have a string S, for which I want to replace every b character with \\ (two forward slashes). So this is what I have: $ S="abc" $ A=$(echo $S | sed 's/b/\\\\/') In bash I get the expected ...
user avatar
0 votes
1 answer
26 views

VT100 Escape codes and TTY interaction: Why `open` a TTY device as opposed to using stdin/stdout

I had a look into escape codes and found some C code that reads the current cursor position. And I guess I have now stumbled over a topic of UNIX/POSIX programming I until now had not much exposure to....
user avatar
  • 301
0 votes
1 answer
20 views

Why menu options/items for editors/commands are declared with uppercase characters?

When nano is running, in the bottom appears the menu options based on ^#, for example ^O ^X etc .. Each one represents ctrl + o ctrl + x respectively Reason of this post: when a new linux user - ...
user avatar
0 votes
0 answers
13 views

URL ampersand escape xdg-open command

I am trying to open a URL using the xdg-open command, but I have tried escaping the ampersand character to no avail; all possible choices don't work in bash. I have tried the following xdg-open "...
user avatar
0 votes
1 answer
54 views

Bash alias with a loop, a sudo, pipes, flags, single quotes and double quotes

I want to make a bash alias of the following command, which works typed out on the command line but all my attempts at making an alias have failed. My only diagnosis is that all those nested quotes ...
user avatar
1 vote
2 answers
45 views

How do I handle strange path characters when piping find output?

I had a problem where I wanted to find the length of each path from a find command. My first attempt was to run something like this: find . -exec sh -c "echo {} | wc -c" \; I got this idea ...
user avatar
5 votes
4 answers
368 views

Convert to uppercase, except for escaped characters

The methods I found break things further down the line by also affecting linebreaks. For example... $ message="First Line\nSecond Line"; $ echo "${message^^}" FIRST LINE\NSECOND ...
user avatar
  • 180
0 votes
3 answers
224 views

bash insert backslash for every slash in string

I have a string that is a path: /tmp/something I need to escape the forward slashes with backslashes: \/tmp\/something How can I do this? Maybe sed? Please point me in the right direction.
user avatar
1 vote
2 answers
52 views

How to execute a string of bash command with command substitution

Suppose I have a bash variable like this: tmp1='$(echo foo)' or tmp2='`echo foo`' How to achieve foo as result? I know that removing the command substitution from the string should work, but is ...
user avatar
1 vote
2 answers
66 views

How to remove duplicates from pipe delimited file using awk with Pipe in Values?

I am trying to remove duplicates based on multiple columns from a pipe delimited file using this How to remove duplicates based on multiple dynamic columns But I found there are pipes within the ...
user avatar
  • 15
0 votes
0 answers
53 views

What is %8F URL encoding character so that stops cut command?

I am working on URL-escape codes. I have a file named escapeCodes which haves all the codes : ! %21 %21 " %22 %22 # %23 %23 $ %24 %24 ... ~ %7E %7E %7F %7F € ...
user avatar
1 vote
1 answer
23 views

How to make color bright with SGR function according to ISO/IEC 6429:1992?

On wiki I found the following code for bright colors for SGR (select graphic rendition) function FG BG 90 100 Bright Black 91 101 Bright Red 92 102 Bright Green 93 103 Bright ...
user avatar
  • 289
-1 votes
1 answer
36 views

What are 7 bit / 8 bit environments for control functions according to ISO/IEC 6429:1992?

I am learning ECMA-48 and I see a lot of notes about 7 bit and 8 bit environments for control functions. For example: NOTE LS0 is used in 8-bit environments only; in 7-bit environments SHIFT-IN (SI) ...
user avatar
  • 289
0 votes
2 answers
58 views

What does SP mean in `CSI Ps SP A` xterm escape command?

I am learning ansi escape codes with xterm. And according to this there is the following escape code: CSI Ps SP A - Shift right Ps columns(s) (default = 1) (SR), ECMA-48. Could anyone explain what ...
user avatar
  • 687
-1 votes
1 answer
52 views

Escape character(single-quotes) not working in Linux alias

I was trying to play around with escape characters in aliases. Here's a simple example : I want to create an alias for echo 'Hello' So I wrote the alias like below : alias sample 'echo \'Hello\' ' But ...
user avatar
2 votes
1 answer
94 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 ...
user avatar
0 votes
0 answers
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 ...
user avatar
0 votes
1 answer
27 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 ...
user avatar
0 votes
1 answer
63 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 ...
user avatar
  • 8,810
0 votes
1 answer
415 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 ...
user avatar
  • 3
1 vote
1 answer
351 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 ...
user avatar
  • 1,151
21 votes
2 answers
2k 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....
user avatar
1 vote
3 answers
34 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 ...
user avatar
0 votes
3 answers
371 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 ...
user avatar
  • 103
0 votes
3 answers
362 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 ...
user avatar
  • 1,949
1 vote
3 answers
839 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\&...
user avatar
1 vote
0 answers
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 ...
user avatar
  • 111
0 votes
1 answer
77 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 | ...
user avatar
1 vote
1 answer
55 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 ...
user avatar
  • 1,295
1 vote
1 answer
226 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' ...
user avatar
  • 213
0 votes
0 answers
29 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, ...
user avatar
  • 101
3 votes
0 answers
57 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 ...
user avatar
  • 551
0 votes
0 answers
80 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, ...
user avatar
0 votes
0 answers
18 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 ...
user avatar
0 votes
0 answers
64 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 ...
user avatar
  • 8,810
0 votes
3 answers
135 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: ...
user avatar
  • 103
0 votes
2 answers
348 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....
user avatar
  • 11
0 votes
1 answer
160 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 ...
user avatar
  • 53
2 votes
1 answer
98 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 \] ...
user avatar
  • 45
2 votes
1 answer
806 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\}-[...
user avatar
  • 294
1 vote
1 answer
201 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 ...
user avatar
  • 569
0 votes
1 answer
35 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 ...
user avatar
  • 1,023
0 votes
2 answers
38 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 ...
user avatar
  • 1
5 votes
4 answers
3k 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 "$...
user avatar
1 vote
0 answers
74 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 ...
user avatar
  • 176
1 vote
1 answer
209 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\(\)\&...
user avatar
  • 22.9k
0 votes
1 answer
104 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-...
user avatar
-2 votes
1 answer
381 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 &...
user avatar
  • 22.9k
2 votes
1 answer
636 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-...
user avatar
  • 83
0 votes
2 answers
1k 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 ...
user avatar
  • 493

1
2 3 4 5
9