The tag has no wiki summary.

learn more… | top users | synonyms

7
votes
3answers
3k views

Where do I find a list of terminal key codes to remap shortcuts in bash?

For example: "\e[1;5C" "\e[Z" "\e-1\C-i" I only know bits and pieces, like \e stands for escape and C- for Ctrl, but what are these numbers (1) and letters (Z)? What are the ;, [ and - signs for? ...
0
votes
1answer
79 views

can someone fix my PS1 for bash

I seem to have too many colour escapes so it only works in some prompts - can someone please correct for me ? PS1='\[\e[0:35m[\u@\e[0:33m\h\e[m \e[0:35m\w]\e[m \e[0:33m`git branch 2> /dev/null | ...
5
votes
2answers
4k views

Change colors in console/virtual terminal

Is there a way to alter all the available colors in console / virtual terminal? By console, I mean what you get after pressing CTRL + ALT + F1 and not anything like xterm or urxvt. So, I guess that ...
4
votes
5answers
414 views

How to use ' in alias?

I have one-line that I want to call using alias. while printf '%s ' "$(df -P / | awk 'NR==2 { print $(NF-1) }')"; do sleep 30; done I tried to escape ' like \' but it didn't work. What is the ...
3
votes
2answers
154 views

Can I make grep treat escaped multiline as a single line?

How can I make tools like grep treat multilines escaped with a backslash as a long single line? Let's say I have some files that looks like this: testvar=test1 \ test2 \ test3 ...
3
votes
2answers
1k views

Calling bash from sh (dash) with commands read from args, and “Unterminated quoted string”/“unexpected EOF”

Just thought I'd document this: I'm trying something very simple - set env variable in bash, and print it out: $ bash -c "a=1; echo a$a;" a $ bash -c "a=1; echo a\$a;" a1 Now I'd want this same ...
1
vote
2answers
214 views

How to print shell variables and values to be able to copy/paste them?

In Bash 4.2.25, the set and env output is not escaped, so shell escapes and any non-printable characters won't be copy-pasteable. Take for example this shell session: $ export foo=$'a\nbar=\baz' $ ...
0
votes
1answer
100 views

Colon breaks the variable subsitution [closed]

I am trying to lookup some C functions so that I could debug while using strace. So I setup a bash function to look it up in firefox (or links), but the substitution falls apart with : and escaping ...
0
votes
3answers
421 views

Can groff create a ps file with interpreted ANSI escape characters?

This question is inspired by this one on SU. How can I print bold or color using lp and ANSI escape sequences? I know how to display, for example, bold text in the terminal: $ echo -e ...
1
vote
2answers
373 views

How to escape text in awful.util.spawn_with_shell command?

Based on a suggestion, I've now got the following call in rc.lua: awful.util.spawn_with_shell('vlc $(xclip -o)') How do I ensure that the output of xclip is escaped so that space characters are not ...
1
vote
1answer
246 views

How to prevent double escaping?

I'm trying to put a bunch of images together into a pdf. I ran gm convert *.jpg out.pdf and it worked, but the images were not in the right order. I found that ls -v orders them correctly so then I ...
0
votes
1answer
62 views

What characters in my printed boot scroll are artifacts?

I am a tech writer and I need to include a boot dump in a document. The dump the engineers gave me has some "bad characters" that I need to delete. What form does a "bad character" take? There are ...
2
votes
1answer
135 views

How can a bash script detect support for window titling escape characters?

I have a debug trap that runs every time I enter a command in bash that sets the window title to indicate what command is running. I'm leaving out all the configuration details and boil it down to: ...
2
votes
1answer
186 views

Confused about when to escape metacharacters in pathnames

I'm pretty confused about under which circumstances do I need to escape metacharacters in pathnames. Consider the following example: I'm in the following working directory: $ echo $PWD ...
1
vote
1answer
411 views

Convert discus output into readable HTML mail

How can I take the DISCUS command output below: and convert it into something HTML email friendly? I've bash scripted something like this: #!/bin/sh discus > /tmp/discus.log touch ...
4
votes
1answer
89 views

how to escape “\”in ssh-copy-id?

I'm connected to Ubuntu server that is a member of a corporate Active Directory domain via likewise-open. The users are in the form mydomain\myuser. I can connect to it via ssh, escaping the \ with ...
5
votes
1answer
5k views

Trouble in script with spaces in filename

I've got a script that scp's a file from remote host back to local. Sometimes the file names contain spaces. scp does not like spaces in its file names. For some reason my attempts at handling the ...
2
votes
1answer
1k views

Shell escape characters for sh -c

I need to execute a command with escaped argument(s) using sh -c. I know the string looks pretty ugly but simple ones don't cause a problem. The output of the echo when passed to sh -c is different ...
3
votes
1answer
164 views

Graphical console applications in Emacs

I am having trouble running htop within an ansi-term in Emacs 24.2. It looks like some of the control characters are not interpreted correctly. I thought ansi-term was capable of handling font ...
1
vote
2answers
798 views

bash scripting - Any function to escape character?

I am trying to automate some of my stuff and facing a issue, the problem boils down to escaping the value that is being passed as a argument to the script. myScript.sh #!/bin/bash loadPatch -name ...
2
votes
1answer
340 views

How to capture text formatting in bash?

The following shell script works but removes colored formatting generated by rspec: #!/bin/bash OUTPUT=`rspec` echo "$OUTPUT" How to preserve the colors?
4
votes
1answer
620 views

Printing colored text using script

When I type below command in the shell I get the OUTPUT in green color. Command echo "\033[32mCONNECTING TO abpwrk\033[m"; Output(in green color) CONNECTING TO abpwrk But if I use the same ...
2
votes
1answer
2k views

Backspace, del, arrow keys not working with interactive programs in Tilda

I currently run Openbox on a light netinstall of Debian. In Tilda, when I use a program like nslookup or winexe, some of my keys do not work properly. Backspace generates ^? Up generates ^[[A ...
2
votes
1answer
187 views

ESC-q doesn't work in tmux with zsh

The title says it all. I use Escq a lot (stashing the current line while I execute another command), and it works fine with Gnome Terminal 3.6.0 + zsh. However, if I start tmux, then it stops working: ...
1
vote
1answer
435 views

Escape Code to Change Cursor Shape

I know that Konsole supports an escape code like "\<Esc>]50;CursorShape=0\x7" that will change the cursor shape. I was wondering if any other terminal emulators support changing the cursor shape ...
2
votes
2answers
660 views

How to copy a piped list of files contained spaces and apostrophes?

I have a list of files generated using find that I want to feed (pipe) to cp. My problem is that the files have spaces and apostrophes in them, leading cp to repeatedly complain that it "cannot stat". ...
1
vote
1answer
77 views

Apostrophe appearing as space

I am trying to insert the following message: friend's mobile number from a file over redhat server into sql server 2005. this message is appearing in the sql server as below: friend s mobile ...
8
votes
2answers
2k views

How do I background an SSH session? [duplicate]

Possible Duplicate: How can I break away from an SSH session that has crashed? I have started an SSH session on the command line, but now I want to get back to my local command line. For ...
6
votes
1answer
4k views

export HTTP_PROXY and special characters in passwd

Suppose for the sake of argument my password below is abc123@ I need to authenticate my linux machine through a corporate proxy to get patches and updates... normally I'd use this: export ...
3
votes
2answers
2k views

Passing a bash command-line argument containing a dot

How can a command-line argument containing a dot (.) be passed? Are there any escape sequences for capturing characters like dot? The following invocation of a bash-script from the shell does not ...
3
votes
3answers
6k views

How can I pass strings with single quotes to grep?

My desired outcome is the following: to recursively search a directory looking for a given string in all found files. The following command is my usual port of call: find ./ | xargs grep -ns 'foobar' ...
8
votes
4answers
4k views

How can I create a file with multiple lines from the command-line?

How can I enter the following contents in a file: Hi abcd I tried using echo "Hi\nabcd" >> ab.txt, but in the file it's written as is (the \n is included, instead of a newline)
4
votes
2answers
329 views

Is there a way to lock terminal's title?

Sometimes there're lots of different sessions opened in own terminal's tabs and it's rather desirable to have theirs initial titles (named by session name) locked since local title tweaks make those ...
8
votes
2answers
602 views

Escape sequences in output of script called from ncurses application

I'm currently running mcabber as my Jabber client (which uses ncurses) in a tmux session on my homeserver. Locally i run iTerm2 as a terminal emulator, which supports the triggering of growl ...
1
vote
1answer
893 views

Opening a file with space from Ruby

When I need to progmatically open in emacs a file that has a space in its name, how can I do that? I've tried these commands from a Ruby script, inside backquotes or popen(…): emacs "foo bar" or ...
3
votes
1answer
1k views

How to bypass GNOME Terminal when sending keyboard input?

When running an interactive shell application, how can I send it a key (or key combination) which would normally be intercepted by GNOME Terminal? In this particular instance it's the F10 key which is ...
3
votes
1answer
2k views

Escaping of meta characters in basic/extended posix regex strings in grep

Is it possible to escape all meta characters of a string inside a variable before passing it to grep? I know similar question has been asked before on SE (here) and also a good explanation here, but I ...
8
votes
4answers
8k views

How to make the terminal display user@machine in bold letters?

I have seen in some screen-shots (can't remember where on the web) that the terminal can display the [username@machine /]$ in bold letters. I'm looking forward to getting this too because I always ...
5
votes
2answers
817 views

is it possible to send a control sequence to a terminal emulator using the keyboard

If you type echo -e '\eZ' and hit return in a shell running in an xterm, you'll see that the terminal emulator prints an obscure code 1;2c. This seems to indicate that xterm interprets the VT100 ...
9
votes
2answers
8k views

inline double and single quote escaping

I'm having trouble with escaping characters in bash. I'd like to escape single and double quotes while running a command under a different user. For the purposes of this question let's say I want to ...
5
votes
1answer
2k views

In Bash, why is PROMPT_COMMAND set to something invisible?

On RHEL6 and CentOS 6, /etc/bashrc sets PROMPT_COMMAND here: case $TERM in xterm*) if [ -e /etc/sysconfig/bash-prompt-xterm ]; then PROMPT_COMMAND=/etc/sysconfig/bash-prompt-xterm ...
2
votes
2answers
1k views

Is the `\` character escaping or becoming part of my ssh key password

If I do: ssh-keygen -N password123\$ -f bobskeys Is \ escaping the $ character or becoming part of the password? Or rather, will bash be doing any escaping before ssh-keygen gets the password ...
17
votes
5answers
13k views

How to clear terminal completely?

When we use clear command or Ctrl+L in terminal, it clears terminal but we can still scroll back to view the last used commands. Is there a way to completely clear the terminal?
4
votes
1answer
1k views

How can I match the page break character in a regular expression?

Nano calls it ^L, but of course, typing something like $ grep -v "^\^L" file doesn't work. Its unicode codepoint is 000C. How can I match it in a regular expression?
4
votes
2answers
347 views

DEC ANSI command sequence questions; cursor movement

So I'm writing a terminal emulation (I know, I should just compile putty, etc.) and am at the stage of plodding through vttest to make sure it's right. I'm basing it on the VT102 for now but will add ...
3
votes
2answers
2k views

Trying to print up down arrow keys

I have this: I read down arrow key abc@abc-ubuntu:~/bashpratice$ read -n 3 key ^[[Babc@abc-ubuntu:~/bashpratice$ I am able to grep for it abc@abc-ubuntu:~/bashpratice$ echo $key | grep '\[' [B ...
2
votes
1answer
246 views

Modifying a set of binary files

I have several binary files with the character 0x04 in them, and I'd like to add an escape \ character before each. Is there a script I can use to do this without needing to manually edit each one?
4
votes
2answers
2k views

How to escape < or > in a parameter in shell?

I'd like to use grep with a PCRE expression that contains the < character. Bash thinks I want to redirect, but I don't want to. How can I escape <?
3
votes
1answer
279 views

Could someone please explain some of these escape codes?

I'm seeing this in my .bashrc file: PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\ [\033[01;34m\]\w\[\033[00m\]\$ ' and I have absolutely no idea what all those ...
14
votes
2answers
2k views

How to avoid escape sequence attacks in terminals?

Reading the details of CVE-2009-4487 (which is about the danger of escape sequences in log files) I am a bit surprised. To quote CVE-2009-4487: nginx 0.7.64 writes data to a log file without ...