Useful shortcuts for vi editor

Showing posts with label escape char. Show all posts
Showing posts with label escape char. Show all posts

Sunday 19 May 2019

Examples of "escape sequences" usage on echo command

To use interpretation of backslash escapes, just need to put "-e" parameters afterward echo command.

Info: "-e" means enable escape sequences

Examples of backslash escapes:
New line;
$ echo -e "Hello World\n"
-> Hello World

Form feed;
$ echo -e "Hello World\fWhat a lovely day\fI like this\f"
-> Hello World
            What a lovely day
                              I like this

Carriage return;
$ echo -e "Hello World\rWorld"
-> World World

Horizontal tab;
$ echo -e "Hello World\tWhat a lovely day"
-> Hello World     What a lovely day

Vertical tab;
$ echo -e "Hello World\vWhat a lovely day"
-> Hello World
           What a lovely day

Null;
$ echo -e "Hello World\0 What a lovely day"
-> Hello World What a lovely day

Clear after all;
$ echo -e "Hello World\c What a lovely day"
-> Hello World

Escape character;
$ echo -e "Go to \\home directory"
-> Go to \home directory

$ echo -e "Go to \"home\" directory"
-> Go to "home" directory

Unicode usage;
$ echo -e "This is turkish lira symbol-> \u20ba"
-> This is turkish lira symbol-> ₺

Sunday 18 September 2016

Oracle escape character examples

First, we need an example data for study.
SQL> insert into departments values ('280','Ad_New',200,1700);

e.g.
SQL> select * from departments where department_name like 'A%';
DEPARTMENT_ID  DEPARTMENT_NAME  MANAGER_ID  LOCATION_ID
10             Administration   200         1700
110            Accounting       205         1700
280            Ad_New           200         1700

SQL> select * from departments where department_name like 'Ad_%';
10             Administration   200         1700
280            Ad_New           200         1700

SQL> select * from departments where department_name like 'Ad/_%' escape '/';
280            Ad_New           200         1700

SQL> select * from departments where department_name like 'Ad__%' escape '_';
280            Ad_New           200         1700