How to perform command
How to perform command
2)pg Command:-
pg a.txt
#clear screen
pg -c a.txt
3)more command :-
less a.txt
5)head command:-
head -5 a.txt
6)tail command:-
tail -5 a.txt
7)wc command :-
wc -l a.txt
wc -c a.txt
wc -w a.txt
8)touch command
-a:-This option changes the access time only
-m:-This option changes the modification time only.
-r:-Uses the access and modification times from the reference file.
touch a
touch b
stat a
touch -m a b
stat a
3)egrep command:-
egrep "mital" * #globally search
egrep "m" a.txt
egrep -c "mm" a.txt #linenumber mathched
egrep -l "mm" a.txt # print filename
egrep -n "mm" a.txt # print linenumber
egrep -r "m*" m.txt
egrep -r "m*" . #recursively searching whole root
=>working with columns and fields
1)cut:-
cat > stat.txt
Andhra Pradesh
Arunachal Pradesh
Assam
Bihar
Chhattisgarh
ctrl+z
2)paste:-
paste a.txt b.txt
paste -d "%" a.txt b.txt
paste -d "1," a.txt b.txt c.txt
cat stat.txt | paste
3)join:-
cat > a.txt
1 aaa
2 vvv
^Z
cat > b.txt
1 xxx
2 ccc
^Z
join a.txt b.txt
join a.txt b.txt > l.txt
=>
1)sort command:-
sort -r a.txt #reverse
sort -n a.txt #numerical character
sort -u a.txt # duplicate remove display
sort -c a.txt #if already sorted no output
sort -k2 a.txt #particular column
sort -m a.txt # sort monthwise
2)unique command:-
cat > music
i love music
i love music
i love music
3)uniq music
uniq -u music #unique line
uniq -d music #duplicate line
uniq -c music # count
#comparing file
cat > a
This is a Line1
^z
cat > b
This is a Line2
^z
1)cmp:-
cmp a b #byte
comm a b #linebyline
3)diff:-
diff a b # >line < line
3)od:-
od -b a.txt #convert file in octal format
od -c a.txt #convert character format
MATHEMATICAL CALCULATION
BC command:-
x=10
y=20
echo $x+$y | bc
factor command:-
factor 10
tee command:-
cat > a
1
2
3
cat >b
4
5
6
wc -l a |tee -a b
cal
cal 2022
COMMUNICATION COMMAND
#The write command in Linux creates a communication line between two logged-in
users through the terminal.
w
write stud #send message on users
#The ping command sends an echo request to a host available on the network.
ping www.google.com
ping 216.58.203.4
ping localhost
sleep 10s
sleep 1m
wait:-
1. The ampersand sign (&) after a command indicates a background job.
2. $! fetches the PID of the last background process. Store the previous PID in a
variable when working with multiple background processes.
ex:-
$sleep 10 &
$jobs -l
$wait
#After 10 seconds (due to sleep 10), the console prints a Done message.