pwd
cd direct3
pwd
ls
touch [Link]
cat>[Link]
Hello, this is session is on unix
^C
cat [Link]
cat>[Link]
this example is on concatenation
^C
cat [Link]
cat>>[Link]
here the content will be appended instead of
overwriting^C
cat [Link]
cp [Link] f1_copy.txt
ls
cat f1_copy.txt
mv f1_copy.txt f1_move.txt
ls -n
ls -i
mv f1_move.txt f2_move.txt
================================================================================
filters
touch [Link]
id|name|age|branch|fees|marks
101|rohith|22|cse|80000|89
102|yusuf|24|ece|56000|80
103|rohan|22|mech|60000|77
104|rehman|23|ce|56000|69
102|yusuf|24|ece|56000|80
103|rohan|22|mech|60000|77
104|rehman|23|ce|56000|69
----------------------------------
id name age branch fees marks
101 rohith 22 cse 80000 89
102 yusuf 24 ece 56000 80
103 rohan 22 mech 60000 77
104 rehman 23 ce 56000 69
102 yusuf 24 ece 56000 80
103 rohan 22 mech 60000 77
104 rehman 23 ce 56000 69
-------------------------
head
------------------------
character based
head -c 2 [Link]
head -n 2 [Link]
head [Link]
------------------------------------------------------------------
tail
---------------------
tail -n 2 [Link]
tail -c 2 [Link]
tail [Link]
---------------------------------------------------------------------------
uniq
no options prints non duplicates and a copy of duplicate lines
uniq [Link]
-----------------------------------
duplicates
prints only duplicates
uniq -d [Link]
--------------------
count frequency of occurences
uniq -c [Link]
prints freq of lines at the start of line
------------------------------
print only unique lines
uniq -u [Link]
===================================================================================
wc
------
wc [Link]
prints lines |word count|char counts| filename
----------------------------
only lines and file name
wc -l [Link]
same with
-c, = characters count
-w, = word count
-L =prints length
===================================================================================
=
sort
-------------
sort [Link]
gives based on ascii or
sort based on column n
sort -k 2 -t"|" [Link]
sort -m -t "|" [Link]
======================================================================
grep
[] grep "grep" [Link]
finds grep in f3
[] grep "grep" *
finds grep in all files in a directory
[] grep -i "grep" [Link]
case insensitive
[] grep -w -i "grep" [Link]
searches whole word -w
case insensitive is added along
[] count number of matches
grep -c -i "grep" [Link]
[] to display only matched pattern
grep -o -i "grep" [Link]
[] show line number
grep -n -i "grep" [Link]
[] print lines that are not matching
grep -v -i "grep" [Link]
[] check for strings starting with
grep -i "^gr" [Link]
[] ending with string
grep -i "grep$" [Link]
===================================================================================
======
sed
[] basic subsitution
sed 's/grep/Grep/' [Link]
[0] subsitute all occureneces in second line
sed '7 s/unix/UNIX/g' [Link]
[] change second occurences in each line
sed 's/unix/UNIX/g2' [Link]
[] replace last occurence
sed '$s/unix/UNIX/g' [Link]
===================================================================================
============
awk
[] print occurences of a word
awk '/unix/{print}' [Link]
[] basic printing 1st column
awk 'BEGIN{FS="|";}
{
print $1;
}
END{
print "done";
}
' [Link]
[] starting of a line
awk '/^[gG]rep/' [Link]