Escape sequences such as encodings of terminal commands and function keys

learn more… | top users | synonyms

0
votes
2answers
25 views

Putting a single quote in a filename [duplicate]

We can a make a directory named $"dollars"&<>\dogs if we surround it with single quotes like the following mkdir '$"dollars"&<>\dogs' However, what if I want to include a ...
4
votes
4answers
147 views

Null and escape characters

I know that a filename in Linux has no restriction whatsoever excpet for two characters '/' and '\0'. I know that '/' is prohibited because it is a directory separator but is there any other reason ? ...
8
votes
1answer
495 views

Caret square bracket square bracket A ^[[A - What does it mean?

Apologies if this has already been asked, but I have no idea how I can find this out myself - when I search for "^[[A" in any search engine it ignores the "^[[" part altogether. Anyway, my question: ...
1
vote
2answers
64 views

How tp Print/echo arrow key in unix - bash, version 3.2.52

How do I print ↑ and ↓ in Unix? Basically I have a script written in bash and I am printing some numbers with whom I want to print arrow keys to show increase/decrease. So how do I literally print ...
1
vote
2answers
41 views

change colour of `echo` for particular line in shell script in Linux?

i want to change colour of echo particular statement in Linux shell script example : echo "invalid entries" echo "valid entries" echo "valid entry" i want red color for echo "invalid ...
0
votes
1answer
56 views

How to escape an input string in Bash [closed]

I'm using the jq tool to handle some JSON in bash. Just one problem, while using this line: PB_ACL="acl="`echo $IMGREQ | jq -r'.data.acl'` Result: echo $PB_ACL // acl= The expected value jq ...
4
votes
3answers
238 views

How to print control characters with escape sequences?

I have defined the color red using tput red=$(tput setaf 1) to colorize warnings in my program. This works fine: printf '%sfail\n' "$red" # prints 'fail' in red But on one occasion I would like ...
3
votes
1answer
55 views

Background color whitespace when end of the terminal reached

I am working with control sequences for text formatting and have stumbled upon some unexpected behavior. I have some text to output, in the middle of this text there is some smaller text block ...
1
vote
1answer
53 views

bash: Passing several space containing filenames

In a bash script I am rasterizing a PDF page by page into single files, in the end the single resulting PNGs are merged again into a PDF like this: convert -monitor /path/to/1.png /path/to/2.png ...
1
vote
1answer
36 views

Backquotes interpretation

I'd like to know what's the difference between these two commands: echo ` echo `date` ` echo ` echo \`date\` ` I know that \ is used to escape characters, but I cannot understand it in this ...
1
vote
2answers
69 views

/bin/sh - echo >> operator not working as expected

I'm writing a shell script that appends binary contents to a file. I tried using this command: echo -en '\x61\x62\x63..' >> /tmp/myfile but that caused the following output: -en ...
2
votes
1answer
42 views

Bell and escape character in prompt string

My prompt string is printed using this statement, printf '\033]0;%s@%s:%s\007' user host /home/user Why does it need an escape character (\033) and a bell character (007)? When i ran the same ...
1
vote
1answer
54 views

LS_COLORS for 256-color terminal

I thought ls colors are defined as <file_type>=[<bg(40-47)>];<font_spec(0:5)>;<font_color(30-37)> but, I recently found this where there are more colors and colors are ...
2
votes
1answer
63 views

How do I properly escape this long su + sed command?

#!/bin/bash wineuser=tom su $wineuser -c "sed -i '$ialias ptgui "wine ~/.wine/drive_c/Program\ Files/PTGui/PTGui.exe\"' /usr/people/$wineuser/config/cshrc.csh" The acutal line inserted to tom's ...
5
votes
1answer
193 views

How do I store colored text in a variable and print it with color later?

If I do git status --short, git lists files that are not tracked with two red question marks in front: I'm trying to store this in a variable and print it with color later. Here's my bash script: ...
2
votes
2answers
100 views

How to escape correctly this word on vim?

I want to substitute this word ${ARRAY1[@]} with $1 on vim substitution command I did :%s:\$\{ARRAY1[\@]\}:\$1:g But give me error about number of repetition,i try also "" but doesn't work How to ...
1
vote
2answers
50 views

Reinterpret terminal output

I have a program that executes some commands in a terminal (for example apt-get update) and stores the output. How can I reinterpret the output, so I can remove all information that is not needed ? ...
1
vote
2answers
68 views

echo with backspace

I am trying to figure out why this happens in bash. Ok this is easy enough. $ echo -e 'a\txy\bc' a xc Ok this is easy enough. $ echo -e 'a\txy\b\b\b\b\b\b\b\b\bc' ac xy Ok this is easy ...
1
vote
1answer
55 views

How use '(' token when using it for searching with ag / awk?

$ ag findVersions( src/java/com/google -bash: syntax error near unexpected token `(' I tried quoting it, escaping it, both were not suitable. $ ag findVersions\( src/java/com/google ERR: ...
1
vote
1answer
60 views

sed exception handling of escaped characters

I want to delete anything that follows a % to the end of the line. Using cat /tmp/foo.txt | sed 's/%.*$//' works great with one exception: I want to ignore any escaped percent signs \%. So with ...
0
votes
1answer
207 views

How to remove the ESC characters from Notepad++

How to remove the ESC characters in black background from Notepad++ v6.7.3
2
votes
3answers
81 views

Command substitutions vs backslash escapes in a quoted string

Consider a double-quoted command substitution with backslash escapes inside it, like this: echo "$(echo '\\')" It prints out \\, whereas I would have expected it to print out only one backslash. My ...
1
vote
1answer
49 views

How to configure the system in order beeing able to hear the sound of the \a escape character?

I read, that if I execute: echo -e "\a" a sound emerges, but frankly speaking, i executed this command several times and no sound happened.
1
vote
2answers
431 views

sh -c: Unterminated quoted string error [duplicate]

I've spent hours trying to understand the following error. My Script CMD="sh -c 'echo \"a\"'" $CMD Error: "a"': 1: "a"': Syntax error: Unterminated quoted string of course when I do echo $CMD ...
1
vote
4answers
84 views

echo \\* - bash backslash escape behavior, is it evaluated backwards?

So in bash, When I do echo \* * This seems right, as * is escaped and taken literally. But I can't understand that, when I do echo \\* \* I thought the first backslash escaped the second one ...
1
vote
1answer
63 views

Apply Escape Characters in Redirected Output

I'm running a program that prints lots of escape characters (like "Esc[1A", to move the cursor up one line), and trying to redirect the output to a log file. When I run the program without ...
1
vote
1answer
103 views

using ansi escape codes to change the background color in xfce4-terminal

This works to change the background color for the entire terminal with xterm: printf '\033]10;%s\a\033]11;%s\a' Blue Red It doesn't work in xfce4-terminal, tho. Is there something that will work? ...
4
votes
4answers
272 views

Viewing man pages with scroll wheel support

I'd like to use the scroll wheel (xterm mouse escape codes) to scroll through man pages, like I can in emacs with xterm-mouse-mode. less doesn't seem to have support for that and short of recompiling ...
2
votes
0answers
123 views

Bash - Convert escape character colored text to BBCode

I want to convert a terminal escape-character colored text file to BBCode colored text. For this i've created an Android logfile with logcat -Cd > /sdcard/logcat.txt. The -C switch adds the color ...
1
vote
1answer
2k views

How to remove junk characters from the file generated by script command in linux [duplicate]

I am using script command to record everything from terminal. But when I am opening the generated file its having lots of junk character. Can anyone help me to remove these junk characters from file ...
5
votes
1answer
143 views

Escaping strings in associative arrays (bash)

I am writing a script which executes a number of programs with arguments. To simplify it as much as possible, consider the following example: programs=( "ls" "echo" ) declare -A parameters ...
1
vote
2answers
152 views

How to escape in YAML the correct way?

On CentOS 7 I am using cloud-init to spin off a droplet using the DigitalOcean API which requires YAML formatting. I got most parts working fine, but struggle on escaping the commands running at ...
6
votes
2answers
252 views

How to determine the current color of the console output?

I know that, if a coloured terminal is available, one can colour the output of it using escape characters. But is there a possibility to find out, which colour the output is currently being displayed ...
3
votes
2answers
796 views

Remove escape characters using sed

I have input coming from pipe which contains special escape characters. For illustration, the stream looks like this: printf "foo.bar\033[00m" > file cat file How can I remove the trailing ...
0
votes
2answers
59 views

Substituting \ for \\ in column

I exported a column of thousands of salts from Mysql for hashcat. Every instance of the character \ was replaced with a double character \\ in the exported column. Is there a way to either sed or awk ...
2
votes
0answers
54 views

How to use ESC sequences to make terminal region scrollable

I have a stm32f1 controlled device that uses USART/USB port to implement a user control interface. Using a standard terminal software (putty/minicom) a user has an ability to enter simple command in ...
0
votes
1answer
157 views

Shell string escape for command arguments [duplicate]

I'm trying to create "/tmp/pwet/foo bar" with this: DIR="/tmp/pwet/foo bar" ARGS="-p ${DIR}" mkdir $ARGS For integration reasons, I have to keep the ARGS building in 2 steps: ARG = some_options + ...
1
vote
1answer
102 views

Echoing Backspace Characters in the Terminal

I'm working with picocom running inside gnome-terminal. I have local echo switched on inside picocom using the -e option, and when I backspace I can see that caret moves backwards, however the ...
5
votes
1answer
60 views

cssh intercepts F10

I am using cssh (cluster-ssh) to ssh to multiple machines simultaneously. Everything works great, except that cssh intercepts F10 key (which in cssh opens menu. This is very unfortunate, because I ...
1
vote
4answers
182 views

What is '“^[b” backward-word' When trying to configure ZSH?

I am on a MAC, and I am trying to figure out shortcuts for my ZSH running on Iterm2. When I type bindkey in the shell, I see (among other mappings), the following: "^[b" backward-word "^[f" ...
0
votes
1answer
116 views

ANSI escapes in Pash prompt are displayed as garbage in Gnome terminal

I would like to use Pash, a PowerShell implementation for mono on my CentOS box. After compilation I started it and got $ mono Source/PashConsole/bin/Debug/Pash.exe ...
2
votes
2answers
204 views

Programmatically detect the ANSI escape code supported by terminal

I am playing around with shell scripts that use ANSI codes and found that for one reason or another different escape codes are supported depending on your terminal/OS. In some cases I get a dump of ...
4
votes
3answers
2k views

How to escape single quotes correctly creating an alias [duplicate]

I've been given this one-liner to know how much memory my processes consume. $ ps -u $USER -o pid,rss,command | \ awk '{print $0}{sum+=$2} END {print "Total", sum/1024, "MB"}' Now I'd like to ...
4
votes
2answers
116 views

Sorting strings with ANSI escape codes

I am trying to print a sorted list of all zsh options, with set options colored green and unset options colored red. I cannot get sort to work properly with on the colored lines though.The below ...
2
votes
2answers
171 views

Non-printing escape sequence: when?

Recently, I have been playing around a lot with color in the terminal and, therefore, with escape sequences, too. I've read the relevant parts of the Bash manpage along with numerous helpful pages on ...
0
votes
2answers
204 views

How to printf an exclamation point in tcsh?

What's the best way to printf an exclamation point in tcsh? It seems like using single or double quotes has no effect on escaping the exclamation point; and using a backspace does work, but then it ...
1
vote
2answers
243 views

When to use bash ANSI C style escape, e.g. $'\n'

I don't use bash often but I recall in the past to pass a tab or newline on the command line I would have to escape the character using the special $ character before a single quoted string. Like ...
0
votes
1answer
123 views

Can I get my iTerm key-combos working in tmux?

I have some shortcut keys defined in iTerm, and I use them for key-mappings in Vim. For example, I map Ctrl-Enter to send a ^[O2P escape code, which I then use to define a Ctrl-Enter key-mapping in ...
2
votes
1answer
72 views

What does xterm's Escape Sequence option do and how do I enable it?

xterm's control-right-click menu contains an option named Escape sequence. It is always disabled ("grayed out") in Ubuntu-14.04. What is this option is used for? How do I enable it? I am looking for ...
5
votes
2answers
281 views

Escape code 50 in xterm

My coworker has the following in the ~/.bash_profile of many of our servers: echo -e "\033]50;SetProfile=Production\a" The text doesn't seem to matter, since this also works: echo -e ...