106 votes
Accepted

Is Vim immune to copy-paste attack?

Short answer: In many situations, Vim is vulnerable to this kind of attack (when pasting text in Insert mode). Proof of concept Using the linked article as a starting point, I was able to quickly ...
user avatar
82 votes

What is `^M` and how do I get rid of it?

This worked for me :e ++ff=dos The :e ++ff=dos command tells Vim to read the file again, forcing dos file format. Vim will remove CRLF and LF-only line endings, leaving only the text of each line ...
user avatar
  • 1,019
44 votes
Accepted

What does CTRL+4 (and CTRL+\) do in bash?

Ctrl+4 sends ^\ Terminals send characters (or more precisely bytes), not keys. When a key that represents a printable character is pressed, the terminal sends that character to the application. Most ...
user avatar
34 votes
Accepted

Dealing with file names with special first characters (ex. ♫)

If the first character of file name is printable but neither alphanumeric nor whitespace you can use [[:punct:]] glob operator: $ ls *.txt f1.txt f2.txt ♫abc.txt $ ls [[:punct:]]*.txt ♫abc.txt
user avatar
  • 43.6k
34 votes
Accepted

Grep: unexpected results when searching for words in heading from man page

If you add a | sed -n l to that tail command, to show non-printable characters, you'll probably see something like: N\bNA\bAM\bME\bE That is, each character is written as X Backspace X. On modern ...
user avatar
33 votes
Accepted

How to use a special character as a normal one in Unix shells?

That very much depends on the shell. Check your shell manual for details. Also note that some characters are only special in some contexts. For instance, in most shells,* and ? are only special in ...
user avatar
30 votes
Accepted

How can I find the common name for a particular glyph?

Try the unicode utility: $ unicode ‽ U+203D INTERROBANG UTF-8: e2 80 bd UTF-16BE: 203d Decimal: ‽ ‽ Category: Po (Punctuation, Other) Bidi: ON (Other Neutrals) Or the uconv utility from ...
user avatar
30 votes
Accepted

Is the "tick" or "acute accent" character ´ (not `) used for anything in Linux shell?

The character sets used historically with Unix, including ASCII, don’t have a tick character, so it wasn’t used. As far as I’m aware no common usage for that character has been introduced since it’s ...
user avatar
27 votes

Unable to remove the $ sign named files using linux?

In alternative to @RomanPerekhrest's answer, this will also work: rm '$commandoutput[0]' as the single quotes will avoid variable expansion. Another way is to start typing rm $ and then hitting ...
user avatar
  • 26.2k
26 votes
Accepted

How to display control characters (^C, ^D, ^[, ...) differently in the shell

When you press Ctrl+X, your terminal emulator writes the byte 0x18 to the master side of the pseudo-terminal pair. What happens next depends on how the tty line discipline (a software module in the ...
user avatar
26 votes
Accepted

Match with grep when pattern contains hyphen "-"

Place -- before your pattern: echo "$a" | grep -Fxc -- "$b" -- specifies end of command options for many commands/shell built-ins, after which the remaining arguments are treated as positional ...
user avatar
  • 13.4k
23 votes
Accepted

BASH and Carriage Return Behavior

Your echo "$a" prints "hello", then goes back to the beginning of the line (which is what \r does), print "again", goes back again, prints "george", goes back again, and goes to the next line (\n). It’...
user avatar
22 votes
Accepted

Search and replace control characters (^@, ^M, ^I....) in vi

Somehow, the space characters are represented by ^@ in vi. It's not vi that did that. Although you type command lines in shells with spaces between the arguments, command lines are actually discrete ...
user avatar
  • 41.3k
20 votes

Can't use exclamation mark (!) in bash?

This also can do curl -v "http://example.org/"'!'"287s87asdjh2/somepath/someresource" or curl -v "http://example.org/"\!"287s87asdjh2/somepath/someresource" Which works because bash concatenates ...
user avatar
  • 877
20 votes
Accepted

Unable to remove the $ sign named files using linux?

Escape $ (and desirably [, ]) sign in your file name with backslash \: rm -rf \$commandoutput\[0\]
user avatar
20 votes
Accepted

What are curly quotes and can I use them in my code?

Curly quotes, or “smart quotes” are used in typography and "straight quotes" will often be automatically changed to curly quotes by various word processing programs. They are sometimes ...
user avatar
  • 33.4k
18 votes

What is the Mode_switch modifier for?

This answer is not meant to contradict @Gilles' answer, but is meant to describe another aspect of xkb Input handling which I feel is "under-illuminated" in his answer. You can use both ...
user avatar
18 votes
Accepted

How to grep '$$$$$'?

It seems that $ is a special character for end of line? Yep, exactly. And there's an end-of-line on each and every line. You'll need to use \$\$\$\$\$ as the pattern, or use grep -F '$$$$$', to tell ...
user avatar
  • 119k
17 votes

Why doesn't the command tr "\'\\\"\?\!" "01234" work?

Not just the shell, but tr itself also interprets backslash as a special escaping character, see its manual for details. So you need to make sure that tr receives literal \\ (two backslashes) when you ...
user avatar
  • 4,535
15 votes

How to search a log file in Linux and escape special characters like square brackets (i.e. [ and ])

The manual does mention you can switch off regular expression search for the whole search string by pressing ^R (CTRL+R) after you press /.
user avatar
  • 259
15 votes
Accepted

How to match a string containing the character "$" with grep?

In this case, the string in $param will be interpreted as a regular expression. This expression contains a $ which anchors the ambari_parameter in the pattern to the end of the match. Since ...
user avatar
  • 275k
13 votes
Accepted

Are periods (".") valid characters in file or folder names?

They are valid and you can use them but yes, there are disadvantages. A period is often used in regular expressions to represent a single character. A period in filenames is often used as the ...
user avatar
13 votes

Grep: unexpected results when searching for words in heading from man page

If you look at any manual page, you'll notice that the headers are in bold. This is achieved through formatting them with control characters. To be able to grep like you're wanting to, these have to ...
user avatar
  • 275k
13 votes

Match with grep when pattern contains hyphen "-"

Besides of @sebasth's great answer, you could tell that PATTERN with grep's -e option to use PATTERN as a pattern (here using the <<< zsh here-string operator instead of echo; see also ...
user avatar
  • 38.6k
12 votes

Can't use exclamation mark (!) in bash?

I have come across the same problem, and my simple solution was to use a variable: E=! curl -v "http://example.org/${E}287s87asdjh2/somepath/someresource" Here the simplicity is that (1) It is ...
user avatar
  • 3,107
12 votes

What is `^M` and how do I get rid of it?

Sed in-place solution without needing to type the special character (you can copy this and it works): sed -i -e "s/\r//g" filename Explanation: -i: in-place -e: regular expression \r: escaped ...
user avatar
12 votes

BASH and Carriage Return Behavior

In the Unix world, a carriage return (commonly encoded as \r in programming languages) is an unremarkable control character. You can have carriage returns inside a line of text, like any other ...
user avatar
12 votes

Is the "tick" or "acute accent" character ´ (not `) used for anything in Linux shell?

Although the ASCII committee thought of ` as a diacritic and ' as an apostrophe, the Unix tradition was to treat them as left and right single quotes (the characters that are now in Unicode as U+2018 ...
user avatar
  • 6,869
11 votes
Accepted

Why is the circumflex/caret character used as a symbol for Ctrl?

The circumflex (^) was equated to the up-arrow character on teleprinters. By the time SunOS and so forth came around, this part was more than 10 years in the past. The same character (replacement) ...
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible