I/O is a device that handle input and output, both for keyboard, floppy, monitor screen, etc.
beside echo, we can use printf command to print out with output standard, in screen or in file with specific format.
below this example:
#!/bin/bash #pr1 url="elvin.enderson.blogspot.com"; number=32; printf "Hi, use printf ala C\n\t\a in bash\n"; printf "My url %s\n %d decimal = %o octal\n" $url $number $number; printf "%d decimal in float = %.2f\n" $number $number
and below is the result
[elvin@Testbed$]./pr1
Hi, use printf ala C
in bash
My url elvin.enderson.blogspot.com
32 decimal = 40 octal
32 decimal in float = 32.00
below it the table for the format control
Format control | information |
%d | data integer format |
%o | octal |
%f | float atau decimal |
%x | Hexadecimal |
Input with read
after echo and printf for output process, now we will use command read.
this command very good to read or accept input from standard input
below is the example
#!/bin/bash #rd1 echo -n "Your name :" read name; echo "Hi $name, How are you?"; echo "message and reply :"; read echo "said $name, $REPLY";
below is the result
[elvin@Testbed$]./rd1 Your name : elvin Hi elvin, How are you? message and reply : i'm fine. thanks said elvin, i'm fine. thanks
0 comments:
Post a Comment