What does the first line binbash mean in a shell script Def

What does the first line \"#!/bin/bash\" mean in a shell script ? Define a symbolic constant MAX to represent value 100 m C program. Use typedef to create types named Int8, Inti6, and Int32 in C program. Define the types so that they represent 8-bit, 16-bit, and 32-bit mtegers on your machine. Assume your machme is a 32-bit machme. To execute a shell script or C program, why do we need to put./before the name of the she! script in some cases? E.g. S./test.sh and S./myCtest

Solution

Dear Student,

There are different type of shell present in linux system, like kshell, cshell,bash etc. And a shell act as an interface between the user and the kernel.

Answer-7- The first line #!/bin/bash indicate that in which shell we are going to execute our script.So if i am using as #!/bin/bash then it means we are executing our script in bash shell(the fullform of bash is bourne again shell) and the shell is present in /bin/bash directory.

Answer-8- A symbolic constant is a name that substitute for a sequence of character that cannot be changed. The character may represent a numeric constant, a character constant, or a string. When the program is compiled, each occurrence of a symbolic constant is replaced by its corresponding character sequence.

So we have to define a macro in our program like MAX as given in question.The representaion will be as follows....

#define MAX 100

below is a c program which implement this..

#include<stdio.h>

#define MAX 100

int main()

{

printf(\"%d\",MAX);

}

Output: 100

So what this program does? Don\'t worry its just replace macro with the defined value.So MAX is replaced with 100.

Answer-9- typedef is a storage class in c programming. The main purpose of typedef is that it replaces existing type variables to its alternative names.

below is the example--

typedef int cheggstudy

so by doing this we are giving another name to int variable as cheggstudy.

So in your question it asked to create typedef name in c programming..

So we can achive this by following c program.

Program--

#include <stdio.h>
int main()
{
    typedef int int8;
    int8 a = 250;
    typedef int int16;
    int16 b = 65000;
    typedef int int32;
    int32 c =2147483647;
    printf(\"%d\ \",a);
    printf(\"%d\ \",b);
    printf(\"%d\ \",c);
}

Output--

So in the above program we have just given the int type to some different values as int8, int16, int32 and initializes the value as 8 bit, 16 bit and 32 bit integer value.I hope you understand this.

Answer-10- We create our script file in vi editor and save the file name with .sh extenstion right..?

and after saving the script we execute that script by ./test.sh or as ./MyCtest.sh.So what a ./ before any file name indicates..?

So dear student the answer is simple ./ symbol before any file at the time of execution indicates that.. This specifically instructs the shell to execute the program in the current directory with the given name. And the dot is just an alias for the current directory.

*****Dear student if you are satisfied with the answer kindly provide your valuable feddback and do comment in the comment section if have any query.*****

 What does the first line \
 What does the first line \

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site