Escape sequences such as encodings of terminal commands and function keys

learn more… | top users | synonyms

1
vote
1answer
34 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 ...
1
vote
1answer
37 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
27 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
47 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
42 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 ...
2
votes
2answers
54 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
683 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
79 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
19 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
41 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
73 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
133 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
337 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
38 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
66 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
85 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
83 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
78 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-' ...
0
votes
1answer
63 views

In vi, convert invisible characters into escape sequences?

My text in vim looks like, i am one line i come in next line i come after a tab space Can the above text be converted like this, i am one line\ni come in next line\n\ti come after a tab space ...
4
votes
1answer
359 views

Match pattern \\\" using grep

I have a json string inside json. This got encoded multiple times and I ended up with many escape backlashes: \\\". The much shortened string looks like, '[{"testId" : "12345", "message": "\\\"the ...
0
votes
2answers
44 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
639 views

Null and escape characters

I know that a filename in Linux has no restriction whatsoever except for two characters '/' and '\0'. I know that '/' is prohibited because it is a directory separator but is there any other reason ? ...
9
votes
1answer
697 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
174 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
73 views

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

I want to change the colour of echo for a particular statement in a Linux shell script example : echo "invalid entries" echo "valid entries" echo "valid entry" I want the red color for echo ...
0
votes
1answer
197 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
404 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 ...
5
votes
2answers
150 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
126 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
40 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
336 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
118 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
148 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
110 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
323 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
106 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
64 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
132 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
134 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
93 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
627 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
144 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
67 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
2k 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 ...
2
votes
4answers
143 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
138 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
174 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
524 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
198 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
3k 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 ...