Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [escape-characters]

Escape sequences such as encodings of terminal commands and function keys

0
votes
3answers
491 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
36 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 ...
0
votes
0answers
54 views

Issue with escape character in UNIX [closed]

ex: grep "foo\|bar" file This executes and when I try to execute again by pressing up button, the command becomes: grep "foo\\|bar" file Is there any fix for getting same command which executed ...
2
votes
1answer
25 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
94 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
44 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
57 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
53 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
113 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
239 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
42 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
33 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
45 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
15 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
213 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
26 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
64 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
159 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
95 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
212 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
47 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
160 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
1k 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
625 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
55 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
337 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
366 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-...
2
votes
2answers
267 views

tmux alt meta zsh shell binding

I have following custom zsh keybindings for the alt (meta) + left and right arrow key withi os x Iterm2 and +Esc setting for meta bindkey "^[^[[D" backward-word bindkey "^[^[[C" forward-word This ...
1
vote
0answers
133 views

Dash escaping hyphen?

I am using Homebrews dash package on MacOS to print a text. echo "Hello World - Test" But I am receiving Hello World \- Test What am I doing wrong?
0
votes
0answers
62 views

send carriage return to java application from a shell

I have a script that invoke a java/scala application, this application asks the user several inputs. I want to automatically give the answers to the java app, so I'm creating this script. I have some ...
1
vote
1answer
172 views

Gawk: backspace preceding a newline doesn't work

I'm using gawk (4.1.3) and it seems I have struck upon a trivial problem. The backspace character doesn't seem to work if it is immediately followed by a newline. awk 'BEGIN{for(i=1;i<=3;i++) ...
0
votes
1answer
320 views

Using extended escape codes in tmux

I use the kitty terminal emulator for my day to day development, and I learned that it has these custom escape sequences for fancy underlines. I really wanted to get them working in vim, and after ...
2
votes
2answers
35 views

col produces incorrect output

I'm trying to post-process the output of script into a more readable form, similar to Removing control chars (including console codes / colours) from script output, but I've noticed that col doesn't ...
2
votes
1answer
82 views

Why do I not need to reset text attributes with less?

This script outputs 5 lines with the third one being underlined: #!/usr/bin/env bash set -eu bold=$(tput bold) reset=$(tput sgr0) underline=$(tput smul) echo 'line 1 line 2 line 3 line 4 line 5' | ...
5
votes
2answers
1k views

Where are escape sequences needed when using tilde ~ operator in awk?

I have a pattern variable with below value: \"something//\\anotherthing' and a file with below contents: \"something//\\anotherthing' \"something//\\anotherthing \"something/\anotherthing' \"...
1
vote
0answers
495 views

Hmac with openssl's command line tool with a key that might contain null bytes

Let's say I want to do an SHA256HMAC digest of a file with the openssl command line utility: openssl dgst -sha256 -hmac "$(cat $KEY_FILE)" -hex "$TARGET_FILE" How can I protect this command against ...
1
vote
1answer
1k views

scp to remote Windows hosts with spaces in path: ambiguous target

I'm trying to scp a file from my local linux machine to a remote Windows machine, and I'm coming up with some inconsistencies in how scp handles Windows file paths with spaces... This works, note ...
0
votes
1answer
325 views

Add escape character in front of all quotation marks in a file

I have a pretty big json file and I would like to add the escape character in front of all quotation marks in it. For example I want to change: "CaptureDuration":0 to \"CaptureDuration\":0. I tried ...
4
votes
1answer
798 views

Making grep understand byte escapes

I'm trying to match against some UTF-8 characters. The problem is grep doesn't translate \x byte escapes, so this fails: echo -e '\xd8\xaa' | grep -P '\xd8\xaa' while this succeeds: echo -e '\xd8\...
-1
votes
2answers
329 views

Backslashing does not work to send a bell via the echo command

The echo command doesn't want to interpret backlash escapes (with -e option attached). For example, I want it to ring a bell with: echo -e \a Nothing happens, except it prints: a or \a How to turn ...
2
votes
1answer
140 views

Why is there no need to escape a sequence to apply a style to the text in a terminal inside tmux?

If I want the ANSI color 0 to be red, in the urxvt terminal, I need to pass the sequence \e]4;0;red\a to the latter: printf '\e]4;0;red\a' I found the general syntax here: OSC 4 ; c ; spec BEL ...
5
votes
2answers
1k views

Bad substitution: no closing “`” in a heredoc / EOF

I'd like to print a man style usage message to describe a shell function like this output man find: NAME find - search for files in a directory hierarchy SYNOPSIS find [-H] [-L] [-P] [-...
12
votes
1answer
2k views

Weird symbols on screen when using grep?

Any idea what could be causing this? Without using grep, the only stuff display there are the ISO codes and empty space. Software used Command: ./trans --id --input /path/to/txt | grep ISO | grep [a-...
1
vote
1answer
92 views

How to get Device Status Report on Busybox?;

I'm trying to get DSR on busybox (to get terminal size), but echo '\x1b[6n' does not report anything, it outputs \x1b[6n.
1
vote
2answers
1k views

bash escaping quotes

I have an interesting challenge for how to escape quotes in a bash script. My bash script has a long curl call with a large -d json structure passed. #!/bin/bash Value4Variable=Value4 curl -s -X ...
2
votes
1answer
1k views

The easiest way to clear scrollback buffer of terminal + some deeper explanation?

Why bother? Clearing scrollback buffer is handy in many ways, for example, when I wish to run some command with long output, and want to quickly scroll to start of this output. When scrollback buffer ...
3
votes
3answers
890 views

Escape unknown characters from string for -exec

I have a find command that finds certain files and directories. That find command then runs rsync with the files and directories found previously as source. The problem is that those files and ...
1
vote
0answers
66 views

Where can I find keyboard key combinations that enter non-printable terminal characters?

For example, in my xterm to get: 000: Ctrl+Space or Ctrl+@ 001: Ctrl+A 002: Ctrl+B 003: Ctrl+C 004: Ctrl+D 005: Ctrl+E 006: Ctrl+F 007: Ctrl+G 008: Ctrl+H 009: Ctrl+I or Tab 010: Ctrl+J or ...
0
votes
2answers
38 views

interpreting near simultaneous Enter and backslash keys

I typed an mv command and intended to hit the Enter key. Perhaps I hit the backslash key at almost the same time. If the Enter key was first, the new line with the green prompt should appear to the ...
3
votes
1answer
7k views

Remove all type of special characters in unix .csv file

I am processing a huge stream of CSV data coming from a source which includes special characters, such as the following: `÷ Þ Ÿ ³ Ù ÷` Here is an example row from a data set which includes these ...