Home » Fun scripts » Linux » 2014 on linux terminal Hasan B 8:16 PM 0 comments Fun scripts Linux 2014 on linux terminal The following script,when executed, will create 2014 on the linux terminal. #!/bin/bash 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_char=$3 f_r_end=$((f_st_row + 5)) 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 "$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" } four(){ set_color start_4_left_col=$((str_dwn_col_1 + 4)) start_4_left_row=$((hrow_be)) str_dwn 3 $start_4_left_col $start_4_left_row "$char" start_4_hori_col=$((str_dwn_col_1 + 4 )) start_4_hori_row=$((hrow_be + 3)) horizontal $start_4_hori_col $start_4_hori_row 5 "$char" start_4_right_col=$((start_4_left_col + 5)) start_4_right_row=$((hrow_be)) str_dwn 7 $start_4_right_col $start_4_right_row "$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;four tput setaf 0 tput cup 9 0 Save the script as "2014.sh" and execute it as follows. $ chmod 777 2014.sh $ ./2014.sh $ What character do you want to use * Share: Facebook Twitter Google+ StumbleUpon Digg Delicious LinkedIn Reddit Technorati
0 comments:
Post a Comment
Click to see the code!
To insert emoticon you must added at least one space before the code.