Wednesday, December 26, 2012

Get the input from command line(STDIN) & Write into File & Display in STDOUT put


#!/bin/bash
echo -e "Enter the Rollno";
read rollNo;
echo -e "Enter the Name";
read name;
echo -e "Enter the Marks";
read marks;
echo "$rollNo|$name|$marks" > studentDb

echo -e " StudentDb is created....."
echo -e " StudentDb records :"
cat studentDb


OUTPUT :

-bash-3.2$ sh HelloWorld
Enter the Rollno
07mx10
Enter the Name
Chidambaram
Enter the Marks
100
 StudentDb is created.....
 StudentDb records :
07mx10|Chidambaram|100

Here
#!/bin/bash            --> the program will run in bash shell
read <variable>     --->  is used to get the input from keyboard, no need to define any data types.
>                           -->   is used to redirect the output into studentDb file
cat studentDb         -->  the file content is displayed in command line

No comments:

Post a Comment

Item - Category Query

      SELECT      msi.segment1 AS Item_Code,       msi.DESCRIPTION AS Item_Desc,       mcs.CATEGORY_SET_NAME,       mck.CONCATENATED_SEGMEN...