Steps to Create a Unix/Linux Program

Step 1 – Open Linux in command mode and make a new directory at Linux                 prompt (say $) to store newly created Linux program file.

$ mkdir prg (Press Enter)       [‘prg’ is the name of created directory]

Step 2 – Now create a Linux file (say Fabonacci.sh, .sh is the extension of                       Linux file) using Unix/Linux ‘vi’ Editor to write Linux program in it .

$ vi  Fabonacci.sh (Press Enter)

Step 3 – Now Press I/i button to insert or start typing of the program inside                   Fabonacci.sh file as ‘Insert mode’ of the program.

Step 4 – Complete the Linux program in Fabonacci.sh file .

Step 5 – Now press ‘Esc‘ button to come out from Insert mode after                                 finishing the code of the program.

Step 6 – Now press colon (:) symbol and press enter.        [: symbol appears                   at the bottom of the code page.]

Step 7 – Now type ‘wq‘ word to come out from ‘vi’ Editor with saving the                     program.

Step 8 – Now, to run/execute/debug the saved program –

$ sh  Fabonacci.sh (Press Enter)          [Either Output or Error will appear – Press Enter/ ]

      • Output will appear –  Press Enter to do next job/work after seeing the result.
      • Error will appear – Press  CTRL+D – Again, repeat step 2-7 to edit the program and save it and execute it again. This same process is repeated until correct output will come.

$ vi  Fabonacci.sh (Press Enter) . . .

Example : Write a shell script program in Linux to show message.
At $ Prompt :

   $ echo Welcome U All in Codershelpline (press enter)

   Output : Welcome U All in Codershelpline

   ----------  OR  ----------
   $ echo Welcome       U     All       in Codershelpline (press enter)

   Output : Welcome U All in Codershelpline

   ----------  OR  ----------
   $ echo "Welcome U All in Codershelpline" (press enter)

   Output : Welcome U All in Codershelpline

   ----------  OR  ----------
   $ echo "Welcome   U     All in        Codershelpline" (press enter)

   Output : Welcome   U     All in        Codershelpline

At vi Editor in a File :

   (Similar as $ prompt but without $)

   echo Welcome U in Codershelpline (press enter)

   Output : Welcome U in Codershelpline  [After execution of created file]
Example : Write a shell script program in Linux to assign values in                               shell variables and display it.
Example : Write a shell script program in Linux to take values from                            the uers and store it into the shell variables and display it.
Example : Write a shell script program in Linux to take values from the users and store it into the shell variables and display its sum.
Example : Write a shell script program in Linux to check the given /accepted value is odd or even.

 972 total views,  1 views today

Categories: Unix/Linux OS

0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.