SHELL PROGRAMMING BASIC IN UNIX - PART 1


📌Highlights: In this post we know about the shell programming basic. This post cover so many basic commands which is useful in programming such as about editor ,type of mods , how deleting files, how cut/copy/paste file contents, how store in buffer, how find /replace files, how insert blank line in file.

➤ vi editor is used to write shell commands. vi editor is a text editor.vim  editor is also used for shell programming.

➤ For opening vi editor we write

    $  vi  filename

Example : $ vi ab1

Now after this vi editor will open.

➤ Shell will run those command written with $ prompt.

➤ Shell has interpreter which will process step by step.

➤ We have two modes:

    1. Command mode

    2. Typing mode.

In command mode we write commands.

In typing mode we write typing text.

➤ Some symbol are used for command as well as contents of file such as:

    ( a-z | A-Z | Ï†-9 | & | $ )

⧭ Note :

 For switching command mode to typing mode press a.

 For switching typing mode to command mode press ESC key.


shell programming basic


 For changing cursor position write:

    n ( h j k l )

where:

    n is number of moves.

    h is for  (←) left move.

    j is for (↓) down move.

    k is for () up move.

    l is for () right move.

Example:

    20 h 20 move left.

    20 j 20 move down.

    20 k 20 move up.

    20 l 20 move right.

They are only work in command mode.


⧭ For Deleting:

    ➤ x    = For Deleting character from current character prompt (CCP).

    ➤ nx  = For Delete n character

    ➤ dw  = For Delete current word from CCP.

    ➤ ndw = For Delete n word.

    ➤ dd   = For Delete lines from CCP.

    ➤ ndd = For Delete n line from CCP.

    ➤ U    = For Undo the last command.

     .     = For Repeat the last comand.


⧭ For Cut / Copy / Paste:


 ➤ dd  is for Delete / Cut line.

 ➤ p(small)  is  for Paste below.

 ➤ P(Capital) is for Paste above.


⧭ For Yanking: 

It is used for storing in buffer.

 ➤ yy is yank

 ➤ nyy is yank n line from ccp lines.

 ➤ nyw is yank n words.


⧭ For Finding / Replace: 


⧭ For Find:

 ➤ / string is used for search string in forward direction of current command prompt (CCP).

 ➤ n is used for continuous last search in same direction.

 ➤ N is used for continuous in opposite direction.

 ➤ ? string is used for search string in the backword direction of current command prompt (CCP)


⧭ For Replace:

➤ /s/string 1/string 2/g is used for forward direction.

    where: string 1 is finding or searching string.

               string 2  is replacing string.

➤ ? s ? string 1 ? string 2 is used for backward direction.


⧭ For Mode Command:

 ➤ wq is used write and quit


 
➤ w is used for save as

 ➤ q is used for quit

 ➤ q1 is used for quit without save.

 ➤ r filename is used for read from fie.



 ➤ set nu is used to display line number.



 ➤ sh is used to go to operating system shell.




⧭ For inserting blank line between two lines:


o (small) is used to insert a blank line below the CCP line.

O (Big / capital) is used to insert blank line above the CCP line.


This is the end of shell programming basic in unix part 1. In part 2 we will continue and know more about shell programming methodology that how to write programs.

No comments:

Post a Comment