Showing posts with label Maths On Linux Terminal. Show all posts
Showing posts with label Maths On Linux Terminal. Show all posts

Monday, September 4, 2023

Maths on Linux Terminal

 for i in {1..10}; do echo | awk -v var=$i '{print var}' ; done

[oracle@stby ~]$  for i in {1..10}; do echo | awk -v var=$i '{print var}' ; done;
1
2
3
4
5
6
7
8
9
10


----------------------------------------------------------------------
$ a=55
$ b=87
$ echo $((a+b))

[oracle@stby ~]$ a=55
[oracle@stby ~]$ b=45
[oracle@stby ~]$
[oracle@stby ~]$ echo | awk -v var0=$a -v var1=$b '{print "division is: ", var1/var0}'
division is:  0.818182


to have division :-
============
[oracle@stby ~]$ printf "%.01f\n" $(echo "scale=1; 4/9" | bc)
0.4
[oracle@stby ~]$ printf "%.02f\n" $(echo "scale=1; 4/9" | bc)
0.40
[oracle@stby ~]$ printf "%.03f\n" $(echo "scale=1; 4/9" | bc)
0.400
[oracle@stby ~]$ printf "%.03f\n" $(echo "scale=3; 4/9" | bc)
0.444
[oracle@stby ~]$ printf "%.06f\n" $(echo "scale=6; 4/9" | bc)
0.444444
[oracle@stby ~]$ # %.0nf 👉"n"--- number of digits after decimal
[oracle@stby ~]$ # scale=6 👉 numbers of decimals digits can be calculated

1. unziping 
unzip -o /path/to/source/*.zip -d /path/to/destination/
-o :- source
-d :- destination

2. cat file_name
3. strings binary_file
4. tar -cvzf backup.tar.gz --remove-files dir/
-cvzf :- create zip file
-xvzf :- extract zip file
--remove-files :- once the file archived it will then get deleted.

5. export day=Monday
unset day

6. date -d 'tomorrow'
date -d 'next week'
date -d 'next sun'
date -d 'next year'
date -d 'next month'
date -d 'next day'
date -d +'%r' for 12 hour timing
date -d +'%R' for 24 hour timing
date + %b   ---> Sep
date + %B   ---> September
date -d '+- days/months/years' +'%Y_%m_%d %H_%M_%s'   ---> like 2023_09_04 09_05_45

7. to see shell 
echo $SHELL

8. to do maths
echo $(( 5+5 ))
printf "%.0f\n" $(echo "scale=1; 2/5" | bc)   ---> 
%.0f ---> 1
%.01f --> 1.0
%.02f --> 1.00
%.03f --> 1.000
i.e %.0nf ---> n means number of digits after decimal.

Enable OpenSSH on Windows 11

Step 1: Install OpenSSH Server You can do this via PowerShell (run as Administrator ): Check if it's already available: Get-WindowsCapab...