Escape sequences such as encodings of terminal commands and function keys

learn more… | top users | synonyms

0
votes
0answers
14 views

How to escape special characters in gnu sed? [duplicate]

I have variables in shell: VAR_IN='Unsafe \t \ string I don't control.' VAR_OUT='some output' I need to change every VAR_IN to VAR_OUT in a stream. Idea is to: sed "s/$VAR_IN/$VAR_OUT/g" # this ...
1
vote
0answers
50 views

How to use ! in the sed command?

Apologize if you feel this question very basic. Anyways, I am typing sed '/[iI]t/ a\\ Found it!' data but it says the error event not found. I tried escaping that ! with backslash \! but it doesn'...
0
votes
1answer
21 views

Colorized tail: How to set default color

I have a function setup to provide color to the tail command using ANSI escape sequences with sed. function colortail { tail -f -n30 $1 | sed -e 's/\(.*MINOR.*\)/\o033[93m\1\o033[39m/' -e 's/.*MAJOR....
6
votes
1answer
145 views

ANSI code translator

Is there any tool that translates text with ANSI code to text-like output? tput cap names or the like? Reason for the inquiry is that I would like to use script or the like and view the resulting ...
0
votes
1answer
20 views

Highlight Vim escape characters e.g. \n

I'm using the Jellybeans vim colorscheme but it doesn't highlight any escape characters. For example if I'm using C++ and have the following... std::string word = "hello\n"; ... the whole string ...
3
votes
4answers
55 views

How to change the background color for exactly one line?

Here are my tries: The last one worked, but it breaks copy-pasting (adding a lot of spaces when copied). Is there a better way? Copyable text: $ PS1='\['$'\x1b[0m\]$ ' $ echo -e "\x1b[41;...
1
vote
2answers
66 views

Keyboard shortcuts C-h, C-m in bash [duplicate]

Bash uses GNU Readline. Readline provides a collection of keyboard shortcuts. However, there are some shortcuts that work on bash and that are not documented in Readline reference. Some examples are: ...
0
votes
1answer
32 views

What \u001B]0;kuba@jcubic: ~\u0007 escape code do?

When using shell in a box this is returned from the server \r\n\u001B]0;kuba@jcubic:~\u0007\u001B[01;32mkuba@jcubic\u001B[00m:\u001B[01;34m~\u001B[00m$ what ESC]0; and \u0007 do?
1
vote
2answers
51 views

What does [?1049h and [?1h ANSI escape sequences do?

When I used shell in a box and when I call less command (echo foo | less) in ajax response there was this code: \u001B[?1049h\u001B[?1h\u001B=\rfoo\r\n\u001B[7m(END)\u001B[27m\u001B[K what does \...
0
votes
2answers
65 views

Create blinking text with echo and escape characters [duplicate]

I have learned about formatting options used in shell scripting, which go like this: \033[37:40mAnyText\033[0m Now I want to echo some text like this: echo -e "SomeText \033[5;31;47mMoreText\033[...
0
votes
2answers
80 views

How to process a file containing quotes?

I know a fair bit about escape characters in BASH. I know that \ will escape the next character, " " will escape all characters except for $ and ", and finally ' ' will escape all characters except ...
2
votes
0answers
39 views

Portable color codes with printf? [duplicate]

There is a color codes script on GitHub suitable for sourcing, which I am modifying for my own purposes. Background I have an odd mix of environments to work in, from a Mac OS terminal, to various ...
1
vote
1answer
23 views

Understanding what is happening when I dump a terminal character sequence with Ctrl-v?

If I want to bind a key-mapping to a function or widget in zsh I have learnt that I first have to hit Ctrl+v - at a prompt, then enter the key sequence I want to use, then use the output in my key-...
2
votes
1answer
33 views

In the SGR number 38 and 48, where do the 2 and 5 numbers come from?

In multi-color-compatible terminals, one can set a color from a 256-color palette by using ESC[38;5;Nm, and any RGB color using ESC[38;2;R;G;Bm. I've been wondering though, where do the "2" and "5" ...
4
votes
2answers
34 views

Question about behavior of control key shortcuts

I am confused about how Ctrl-key combinations work in terminal. In bash man page, there are various combinations such as: C-e - go to end of the line C-f - go one character forward etc. But then ...
0
votes
0answers
38 views

escaped strings inside variable returned in single quotes

I have a number of mp3 files without correct file names. What I wish to do is to create a script that will read the artist and title from mp3 tag and rename the file according to the tag. The script ...
3
votes
2answers
146 views

posting data using cURL in a script

I'm trying to write a simple alternative script for uploading files to the transfer.sh service. One of the examples on the website mentions a way of uploading multiple files in a single "session": $ ...
6
votes
1answer
274 views

How to use less in a script without getting ESC escape characters?

When I use less at the command line the output is like but when I use less from within a bash script I get: How can I use less in a bash script and not get all the escape characters and have it ...
1
vote
1answer
130 views

Escape strings to be posted via curl

I am trying to make a script that takes some atom feeds and posts them to slack through the Slack API via curl. What I have now works for simple texts, but some of them have double quotes or & ...
0
votes
2answers
39 views

Problem with understanding keys bindings

I have a settings and a zsh session ~ bindkey | grep help "^[H" run-help "^[h" run-help Why when i press "Control + [ + h" word under cursor removes and nothing happens, but if i press "Alt + h"...
15
votes
2answers
569 views

How do I use grep while keeping the original text color? [duplicate]

For example, I have a output: Hello, this is the output. (let's say that for example hello is colored red, and the is colored green, and output is colored purple). Now, let's say that this is the ...
1
vote
0answers
22 views

How to remove a single quote from a file name? [duplicate]

I have some podcasts on my radio server which contain a timestamp when they should be played. I noticed one of them is put into single quotes 'filename.mp3', and I'm unable to remove them. Check this: ...
5
votes
3answers
90 views

Is there any objective benefit to escape sequences over tput?

In people's '.*rc' files I see online or in various code, I tend to see a lot of people who manually use ANSI escape sequences instead of using tput. I had the understanding that tput is more ...
3
votes
1answer
71 views

What does it mean when characters appear on the prompt after an operation?

Compare the following two commands: mysqldump database_name --hex-blob -uuser_name -p | tee database_name_tee.sql mysqldump database_name --hex-blob -uuser_name -p > database_name_out.sql If I ...
0
votes
0answers
54 views

double quote single quote combination BCP on Linux

Can someone show me the correct way to structure this command? FYI - I think this boils down to an escape issue. There are several posts close but I have yet to find a solution which will run as a ...
-2
votes
2answers
61 views

blink code(escape code) has been removed?

According to Bash tips: Colors and formatting (ANSI/VT100 Control sequences) I attemped to active blink code in my program, But may be blink code has been eliminated. Is it true? If is not true, ...
1
vote
1answer
170 views

What do \t and \a mean in a shell script?

What do \t and \a perform or do in a script? For example, I am writing a script and it goes like this \t it displays a simple script \a
4
votes
2answers
471 views

Is it possible to use ANSI color escape codes in Bash here-documents?

I'm printing a message in a Bash script, and I want to colourise a portion of it; for example, #!/bin/bash normal='\e[0m' yellow='\e[33m' cat <<- EOF ${yellow}Warning:${normal} This script ...
3
votes
4answers
108 views

Bash converting path names for sed so they escape

I'm having a problem with a script. It is meant to change a value in a file called %DIR% so that it becomes a path name. The problem is the slashes in the directory name upset sed, so I get weird ...
3
votes
1answer
87 views

What's the maximum length for a multibyte escape sequence?

ESC sends \x1b. That's 1 byte: the actual escape character. Page Up sends \x1b[H. That's 3 bytes. F2 sends \x1b[OQ. That's 4 bytes. F5 sends \x1b[15~. That's 5 bytes. What's the maximum length for ...
0
votes
2answers
75 views

awk FS with back slashes

I use the command find . -maxdepth 1 -not -type d which generates output like ./filename.1.out I pipe the find command output to awk. The goal is to split on either the literal ./ or .. I have it ...
6
votes
2answers
449 views

What is the gnome-terminal ANSI escape sequence for “CTRL + arrow/s”?

I am trying to configure my bash ~/.inputrc to these settings (Note: ←, → mean the left and right arrow keys) Ctrl + ← - should jump back a word Ctrl + → - should jump forward a word Currently I ...
1
vote
1answer
68 views

Double quotes issue in bash script

I have a shell script I am trying to get working. I need the output to be a certain way and I know I'm just not escaping the characters correctly. script: #!/bin/bash set -x DATE=$(date +%Y-%m-%d-%M)...
1
vote
1answer
152 views

Is it possible to do a here-document in one line or echo verbatim?

I often find myself testing out a command (e.g. cat file | awk 'stuff') in the shell and when I'm satisfied with the way it works, I append the command to a script file. Let's say this is the command ...
1
vote
1answer
63 views

Maximizing tmux session shows weird ANSI Sequences

I have a tmux session inside Putty. It was fine for past many months, but now I see a strange thing. When I maximize a normal Putty window, and if cursor is not on a new line, then I get some weird ...
2
votes
2answers
104 views

sed to match pattern between matching curly braces

From a pattern such as [string 1]{string 2} I want to extract string 2, the string between the last pair of matching curly braces -- that is delete [string 1] and the open { and close }. My ...
3
votes
2answers
56 views

How to interpret ' character in a string passed through SSH

New to BASH and Linux and need some quick help. I have written a quick bash script that asks the user for a username and password from the command line and passes that info to a remote server later ...
5
votes
2answers
154 views

Issue with column command and color escape codes

I'm colorizing the header of a table formatted with column -ts $'\t' Works well without color codes, but when I add color codes to the first line column doesn't properly align the output. Without ...
19
votes
3answers
784 views

How to prevent random console output from breaking the terminal?

There are many questions on SE that show how to recover from terminal broken by cat /dev/urandom. For those that are unfamiliar with this issue - here what it is about: You execute cat /dev/urandom ...
1
vote
2answers
97 views

Escape characters from echo -e

I have the following in my .bashrc file I use for a log: function log(){ RED="\e[0;31m" RESET="\e[0m" echo -e "${RED}$(date)" "${RESET}$*" >> "$HOME"/mylog.txt } But when I do ...
0
votes
0answers
32 views

Escape special chars in csh alias

I want to create an alias for the following thing: diff -r <dir1> <dir2>| grep diff | grep -v "Files " | grep -v "\.git" \ | awk '{print "tkdiff " $3 " " $4}' I am getting lost with ...
2
votes
2answers
77 views

How to escape metacharacters for egrep like metaquote from Perl?

Perl has a function called metaquote() to escape all special characters for a regular expression. Is there an equivalent technique for egrep? Example: If I am searching for the string abc.def.ghi, I ...
2
votes
2answers
128 views

Why does “shift-tab” result in “Escape” in the terminal?

I just noticed this by accident. I use the vi readline mode (run set -o vi in bash) so it is particularly noticeable; in emacs readline mode I don't think Esc does anything, but in vi mode it exits ...
3
votes
2answers
165 views

Shell-independent escaping for strings in scripts

I just struggled (again) over this: # only in bash NORM=$'\033[0m' NORM=$'\e[0m' # only in dash NORM='\033[0m' # only in bash and busybox NORM=$(echo -en '\033[0m') The goal is to include special ...
3
votes
4answers
498 views

Executing a 'perl command' from shell and executing the same command from perl script using system command

I am not able to take care of special characters. I have the following perl script. while(@mapping_array[$i]) { chomp(@mapping_array[$i]); my @core= split ( / / , $mapping_array[$i]) ; @...
0
votes
1answer
44 views

expansion with escape character help

I am having trouble doing expansion with this because of the escape character. UNF\1122 Right now I am trying to stick with the really simple example of: ps -ef | grep $USER Eventually after I ...
1
vote
1answer
99 views

Why is vi (but not cat) showing ^[[31m[^[[m^[[31m" after I use sed and output to a file I then edit? [closed]

When I use cat Variables/user-extensions.js | sed -e 's/css/XXX/' on an input file of the form storedVars["css_body"] = "css=body"; storedVars["css_main"] = "css=main"; I see output such as ...
2
votes
3answers
214 views

How to substite a " in awk?

For example, I need to change a " into the word quote in to change a string with a " at some point into a string with a quote at some point I have tried: $ echo 'a string with a " at some ...
0
votes
0answers
154 views

Calling a password checking command from PHP using exec() - how to escape user input?

I am working on a PHP-based website where the login form needs to authenticate against local users on the system via PAM - in other words, they should be able to login successfully if they enter a ...
1
vote
2answers
139 views

Find OS X terminal key combination/escape sequence for Ctrl-'

One of my Emacs keybindings is C-', which works well in GUI. In terminal however, it is not being recognised. I understand that I need to figure out the actual characters sent to the terminal by C-' ...