News for hackers. Stuff that matters.
Re:Interesting commands for the Linux shell by joosters on Thursday September 14, 2017 @06:41AM (#15246604)

   grep -P "\t"
Not criticising the author here, as grep -P is good, but you might not also know that you can enter tabs and other codes in bash by pressing ctrl-v. So you could also type:

   grep "[ctrl-v]TAB"
Re:Interesting commands for the Linux shell by reacweb on Thursday September 14, 2017 @07:37AM (#15246893)
I know Linux since 1992 (main OS since 2009) and I did not know that. thank you very much
Re:Interesting commands for the Linux shell by l0b0 on Thursday September 14, 2017 @07:33AM (#15246870)
The first alternative is still preferable, since it's actually readable.

You can also do $'\t' in at least Bash (and probably Zsh).

Re:Interesting commands for the Linux shell by joosters on Thursday September 14, 2017 @08:22AM (#15247203)
Oh, agreed. But the ctrl-v trick is useful in general anywhere where you'd like to put a special character in an input or command.
Re:Interesting commands for the Linux shell by michaelcampbell on Thursday September 14, 2017 @11:45AM (#15249145)
Under the presumption that he means `bash` when he says "the Linux shell", does the Ctrl-v trick work in both emacs and vi modes?
Re:Interesting commands for the Linux shell by Pete_D on Thursday September 14, 2017 @01:22PM (#15250215)
Yes; it's a readline command called quoted-insert and is by default bound to ctrl-V in both modes.

    $ set -o vi; bind -q quoted-insert
    quoted-insert can be invoked via "\C-v".
Re:Interesting commands for the Linux shell by flachsechs on Thursday September 14, 2017 @07:31AM (#15246865)
this works in vim also.
Re:Interesting commands for the Linux shell by vram22 on Thursday September 14, 2017 @08:09AM (#15247115)
And Ctrl-V does not work in GVim on Windows, but Ctrl-Q does instead. E.g. if you have a text file with mixed Unix and DOS/Windows line endings, like Ctrl-J (line feed == LF == ASCII 10) and Ctrl-M (carriage return == CR == ASCII 13) + Ctrl-J, you can search for the Ctrl-Ms with /Ctrl-Q[Enter] and for tabs with /Ctrl-Q[Tab]. When you type the Ctrl-Q, it does not show as Ctrl-Q, but as a caret (^). And you can also use the same quoted Ctrl-M (Enter) pattern in a search and replace operation to remove them globally, by replacing them with a null pattern:

:%s/Ctrl-Q[Enter]//g[RealEnter]

or replace each tab with 4 spaces:

:%s/Ctrl-Q[Tab]/[4 spaces]/g[RealEnter]

where [RealEnter] means an unquoted Enter.

This is mainly useful for making such changes in a single file (being edited) at a time. For batch operations of this kind, there are many other ways to do it, such as dostounix (and unixtodos), which come built-in in many Unixen, or tr, maybe sed and awk (need to check), a simple custom command-line utility like dostounix, which can easily be written in C, Perl, Python, Ruby or any other language that supports the command-line interface (command-line arguments, reading from standard input or filenames given as command line arguments, pipes, etc.).