Skip to content

Commit a92582f

Browse files
committed
Create eg_echo.sh
1 parent 48c00e1 commit a92582f

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

BashExample/eg_echo.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
# Commonly used commands with this file:
4+
# bash --version
5+
# cat eg_echo.sh
6+
# bash eg_echo.sh
7+
8+
echo 'Executing file: '$0
9+
10+
echo Hello, world
11+
12+
# To get rid of the automatically inserted \n with -n flag
13+
echo -n 'Hello, world'
14+
15+
# printf in Bash
16+
echo # add a termination charater to compensate previous -n flag
17+
printf '%s = %d\n' 'Line' $LINES
18+
19+
# - sign forces to allign to the left
20+
printf '%-10.10s = %5.3f\n' 'Const PI' 3.14159265359
21+
# without -sign, alligns to the right
22+
printf '%10.10s = %5.3f\n' 'Const PI' 3.14159265359

0 commit comments

Comments
 (0)