-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path02_Helper.sh
More file actions
58 lines (41 loc) · 1.01 KB
/
02_Helper.sh
File metadata and controls
58 lines (41 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/sh
# Author : Ninad Gawad
# Basic Helper Shell Script
## Find Machine uptime
echo `uptime`
## Find Processes running by keyword
ps -ef | grep <keywork>
## Find memory Information
cat /proc/meminfo
## Find CPU Information
cat /proc/cpuinfo
## Find a keyword in all files ending with *.log
grep -i <keyword" *.log
## Filer Log file to show column 1 ^ 4
awk '{print $1,$4}' apache.log
## Show top 10 lines in a file
head -10 /tmp/test.logs
## Find the OS
uname -a
## Find the current user
id
## Opeb VI editor for a file data.csv
vi data.csv
## Show Last 10 lines in a file
tail -10 /tmp/test.logs
## Show MD5 hash for a file
md5sum file.dat
46798r57fca45c46a84b7419f8b740123
## Sed to replace old value in the file with new value
sed -i "/s/OLD_VALUE/NEW_VALUE" data.csv
# Unix Function to add two arguments passed to it
add()
{
numberA=$1; # Argument 1
numberB=$2; # Argument 2
if [ $# -ne 2 ]; then
echo “ Enter two numbers to add “;
fi
sum=$((number1+number2));
echo “ Sum of $1 + $1 = $sum “;
}