Skip to content

Commit

Permalink
Create eg_echo.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
XuhuaHuang committed Oct 30, 2021
1 parent 48c00e1 commit a92582f
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions BashExample/eg_echo.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

# Commonly used commands with this file:
# bash --version
# cat eg_echo.sh
# bash eg_echo.sh

echo 'Executing file: '$0

echo Hello, world

# To get rid of the automatically inserted \n with -n flag
echo -n 'Hello, world'

# printf in Bash
echo # add a termination charater to compensate previous -n flag
printf '%s = %d\n' 'Line' $LINES

# - sign forces to allign to the left
printf '%-10.10s = %5.3f\n' 'Const PI' 3.14159265359
# without -sign, alligns to the right
printf '%10.10s = %5.3f\n' 'Const PI' 3.14159265359

0 comments on commit a92582f

Please sign in to comment.