We’re rewarding the question askers & reputations are being recalculated! Read more.
111

The ^M is a carriage-return character. If you see this, you're probably looking at a file that originated in the DOS/Windows world, where an end-of-line is marked by a carriage return/newline pair, whereas in the Unix world, end-of-line is marked by a single newline. Read this article for more detail, and also the Wikipedia entry for newline. This article ...


106

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 create a web page with the following code, using HTML span elements and CSS to hide the middle part of the text so that only ls -la is visible to the casual ...


99

The exclamation mark is part of history expansion in bash. To use it you need it enclosed in single quotes (eg: 'http://example.org/!132') or to directly escape it with a backslash (\) before the character (eg: "http://example.org/\!132"). Note that in double quotes, a backslash before the exclam prevents history expansion, BUT the backslash is not removed ...


62

As well as the answer given by Daniel, you can also simply turn off history expansion altogether if you don't use it with set +H.


46

The file has a name, but it's made of non-printable characters. If you use ksh93, bash, zsh, mksh or FreeBSD sh, you can try to remove it by specifying its non-printable name. First ensure that the name is right with: ls -ld $'\177' If it shows the right file, then use rm: rm $'\177' Another (a bit more risky) approach is to use rm -i -- * . With the -i ...


39

Most UNIX operating systems have a utility called dos2unix that will convert the CRLF to LF. The other answers cover the "what are they" question.


36

A simpler way to do this is to use the following command: dos2unix filename This command works with path patterns as well, Eg dos2unix path/name* If it doesn't work, try using different mode: dos2unix -c mac filename -c Set conversion mode. Where CONVMODE is one of: ascii, 7bit, iso, mac with ascii being the default.


36

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 function keys are encoded as escape sequences: sequences of characters that start with the character number 27. Some keychords of the form Ctrl+character, and a ...


35

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


34

Whether such output can be exploited depends on the terminal program, and what that terminal does depending on escape codes that are being sent. I am not aware of terminal programs having such exploitable features, and the only problem now would be if there is an unknown buffer overflow or something like that, that could be exploited. With some older ...


33

Most terminal emulators will send back some response, if they receive certain escape sequences (have a look at the xterm control sequences documentation). E.g., you can send \e[0c to a VT100-like emulator and it will send back the device attributes, something like \e[?1;2c (This is probably what Keith observed.) But these answers are not arbitrary strings. ...


33

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 terminals, the character ends up being written over itself (as Backspace aka BS aka \b aka ^H is the character that moves the cursor one column to the left) with ...


30

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 the ICU package: $ printf %s ‽ | uconv -x any-name \N{INTERROBANG} You can also get information via the recode utility: $ printf %s ‽ | recode ..dump UCS2 ...


28

Mode_switch is the old-style (pre-XKB) name of the key that is called AltGr on many keyboard layouts. It is similar to Shift, in that when you press a key that corresponds to a character, you get a different character if Shift or AltGr is also pressed. Unlike Shift, Mod_switch is not a modifier in the X11 sense because it normally applies to characters, not ...


28

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 become available; nor would it, since it’s not included in POSIX’s portable character set. ` was apparently originally included in ASCII (along with ^ and ~) to ...


27

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 Tab; the shell will autocomplete the filename, escaping characters as needed.


26

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 list contexts, in POSIX or csh-like shells, ~ is only special at the beginning of a word or following some characters like :. Same for = in zsh. In some shells, [ ...


25

Short answer: restrictions imposed in Unix/Linux/BSD kernel, namei() function. Encoding takes place in user level programs like xterm, firefox or ls. I think you're starting from incorrect premises. A file name in Unix is a string of bytes with arbitrary values. A few values, 0x0 (ASCII Nul) and 0x2f (ASCII '/') are just not allowed, not as part of a ...


23

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 in the buffer. then :set ff=unix and finally :wq


23

Typically files ending with a ~ are backups created by editors like emacs, nano or vi.


20

Interpretation of *.* under old Windows/DOS systems The significance here is more related to Windows/DOS than to Unix/Linux. On old Windows/DOS sytstems it was a 'wildcard' pattern. Wildcard patterns were used for matching filenames in a similar manner to Unix globs. The *.* wildcard was commonly used to match any file. As with a Unix glob, the * will ...


20

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


20

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 arguments.


19

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 kernel that sits in between the master side (under control of the emulator) and the slave side (which applications running in the terminal interact with)) is ...


19

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’s all perfectly normal, but as chepner points out, it doesn’t have anything to do with Bash: \r and \n are interpreted by the terminal, not by Bash (which is ...


18

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 grep to use the pattern as a fixed string instead of a regular expression. Or a shorter version regex pattern: \$\{5\} in basic regex or \${5} in extended ...


17

I would personally do single quotes, but for completeness, I will also note since it is a URL, you can encode the ! as %21, e.g. curl -v http://example.org/%21132 .


17

backspace is only moving the cursor backward. backspace (or delete or whatever character depending on the configuration) deletes the last printed character only when these conditions are met: it is typed on the keyboard, not a command output like echo in your example the terminal device is in cooked mode (the usual case) If you want to erase the c in ...


17

The thing is, the kernel doesn't care one bit how the applications interpret the data it is given as a filename. Let's imagine I have a C application that deals with exclusively UTF-16 strings. And I enter, via a properly configured input method, the ∯ symbol (Unicode 0x222F) into the "Save As" prompt/dialog. If the application doesn't do any form of ...


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