UNIX Commands
UNIX Commands
cd direct3
pwd
ls
touch file1.txt
cat>file1.txt
Hello, this is session is on unix
^C
cat file1.txt
cat>file1.txt
this example is on concatenation
^C
cat file1.txt
cat>>file1.txt
here the content will be appended instead of
overwriting^C
cat file1.txt
cp file1.txt 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 f1.txt
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 f1.txt
head -n 2 f1.txt
head f1.txt
------------------------------------------------------------------
tail
---------------------
tail -n 2 f1.txt
tail -c 2 f1.txt
tail f1.txt
---------------------------------------------------------------------------
uniq
uniq f1.txt
-----------------------------------
duplicates
prints only duplicates
uniq -d f2.txt
--------------------
count frequency of occurences
uniq -c f2.txt
------------------------------
print only unique lines
uniq -u f2.txt
===================================================================================
wc
------
wc f2.txt
same with
-c, = characters count
-w, = word count
-L =prints length
===================================================================================
=
sort
-------------
sort f1.txt
gives based on ascii or
======================================================================
grep
finds grep in f3
[] grep "grep" *
sed
[] basic subsitution
awk
[] starting of a line
awk '/^[gG]rep/' f3.txt