Linux World
Pages
Home
Programming
Computer Architecture
Tit Bits
Trouble Shoot
Kernel Related
Quizzes
Linux Tips
Follow @Linux_world
Search
Creating 2018 on the terminal
Here is a bash script which can be used to create the text 2018 on the terminal using any characher of your choice.
#!/bin/bash #create 2017 on terminal using any user specified character str_dwn() { rows=$1 s_start=$2 char=$4 str_st_row=$3 rows_end=$((str_st_row+rows)) for((i=str_st_row;i<rows_end;i++)) do tput cup $i $s_start printf "$char " done echo"" } backslash() { b_st_row=$1 b_st_cols=$2 b_char=$3 b_r_end=$((b_st_row + 5 )) for((p=b_st_row;p<b_r_end;p++)) do tput setaf $4 tput cup $p $b_st_cols printf "$b_char " ((b_st_cols++)) done echo"" } forward() { f_st_row=$1 f_st_cols=$2 f_len=$3 f_char=$4 f_r_end=$((f_st_row + $f_len)) for((i=f_st_row;i<f_r_end;i++)) do tput cup $i $f_st_cols printf "$f_char " ((f_st_cols--)) done echo"" } horizontal() { hrow=$2 hstart=$1 hcols=$3 char=$4 end=$((hstart + hcols)) for((i=hstart;i<=end;i++)) do tput cup $hrow $i printf "$char" done echo"" } gen_rand() { num1=$1 if [ $num1 -eq 0 ] then temp=$(($RANDOM % 2)) rand=$((temp + 2)) else temp=$(($RANDOM % 5)) rand=$((temp + num1)) fi } two() { hstart_2=$1 hrow_be=$2 hcols_2=$3 char=$4 color=$5 set_color horizontal $hstart_2 $hrow_be $hcols_2 "$char" st_row_2=$((hrow_be+1)) f_st_cols_2=$((hstart_2+hcols_2)) forward $st_row_2 $f_st_cols_2 5 "$char" $color hstart_2_lo=$start hrow_2_lo=$((hrow_be+6)) hcols_2_lo=5 horizontal $hstart_2_lo $hrow_2_lo $hcols_2_lo "$char" } zero() { set_color hstart_0=$((f_st_cols_2 +4)) hcols_0=5 horizontal $hstart_0 $hrow_be $hcols_0 "$char" str_dwn_col_0=$hstart_0 str_dwn_row_0=$((hrow_be + 1)) str_dwn 6 $str_dwn_col_0 $str_dwn_row_0 "$char" hstart_0_lo=$((f_st_cols_2 +4)) hcols_0_lo=6 hrow_0_lo=$((hrow_be+6)) horizontal $hstart_0 $hrow_0_lo $hcols_0 "$char" str_dwn_col_rig_0=$((hstart_0 +5)) str_dwn_row_rig_0=$((hrow_be + 1)) str_dwn 6 $str_dwn_col_rig_0 $str_dwn_row_rig_0 "$char" } one() { set_color str_dwn_col_1=$((str_dwn_col_rig_0 + 4)) str_dwn_row_1=$((hrow_be)) str_dwn 7 $str_dwn_col_1 $str_dwn_row_1 "$char" } eight() { set_color set_color hstart_8=$((str_dwn_col_1 +4)) hcols_8=5 horizontal $hstart_8 $hrow_be $hcols_8 "$char" str_dwn_col_8=$hstart_8 str_dwn_row_8=$((hrow_be + 1)) str_dwn 6 $str_dwn_col_8 $str_dwn_row_8 "$char" hstart_8_lo=$((f_st_cols_2 +4)) hcols_8_lo=6 hrow_8_lo=$((hrow_be+6)) horizontal $hstart_8 $hrow_8_lo $hcols_8 "$char" str_dwn_col_rig_8=$((hstart_8 +5)) str_dwn_row_rig_8=$((hrow_be + 1)) str_dwn 6 $str_dwn_col_rig_8 $str_dwn_row_rig_8 "$char" hstart_8_lo=$((f_st_cols_2 +4)) hcols_8_lo=6 hrow_8_lo=$((hrow_be+3)) horizontal $hstart_8 $hrow_8_lo $hcols_8 "$char" } set_color(){ color=$RANDOM color=$((color%6)) tput setaf $color } cols=`tput cols` mid=$((cols/2)) start=$((mid-16)) echo "What character do you want to use" read char tput clear rows=5 begin_row=2 num_cols=6 two $start $begin_row $num_cols "$char" $color;zero;one;eight tput setaf 7 tput cup 9 0
We have entered "&" as the character, and you should see the output as shown below.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment