Thursday, 1 January 2015

Unix - Session 2

#ls
#ls -l | more
long format
#ls -lt | more
latest is top
#ls -lta | more
dot files will be shown along with hidden files
#ls -lt xilink
xilink is a directory name

d stands directory

#pwd
#cd ..
#cd
it goes to home directory

cd ~/directryname
echo $cwd

mkdir krishna
emacs welcome.txt

more welcome.txt
ls -lt
chmod 700 welcome.txt  rwx by  me
chmod 600  welcome.txt  rw
chmod 644 welcome.txt


mkdir test
ls -l
rmdir test
rm welcome.txt
ls -lt



cp welcome.txt krishna_welcome.txt

#hostname
#uname -n
#uname -a
#clear
#who
#whoami
#ls -lA
#ls -A
list Almost all
#ls -a list all
#ls -A -l

spacebar or f
one page forward
b
one page backward
[Enter]or j
one line forward
[Enter] or k
one line backward
/foo
serarches forward for expression foo
#less mynewtestfile.txt
#tail -f loop.out
ctrl+c get out of it
tar -cvf myarchive.tar*

tar -xvf myarchive.tar
gzip myarchive.tar
ls -la
gunzip my
bzip2 my
bunzip2 myarhive.tar.bz2


tar czvf myarchive.tar.gz*
ls
ls -la
tar cjvf myarhcive.tar.bz2*

ls
zip myzip mydir mydir1 testfile


head hostname.txt
scp -P 1209 hostname.txt krishna.edu:-/me5013

wget krihna.com.files\krishna.123.pdf

#ls
#grep 'theme' index.php
#grep 'theme' themes/*
#cd themes/
#grep -r 'theme' themes/*
grep -r 'username' .

dot means current directory
grep -rl 'username'
grep -v 'theme' readme.txt
grep 'theme' readme.txt
grep -n 'theme' readme.txt
grep -i 'this' readme.txt
grep -r 'search string'
grep -rn 'search string'

:wq<Enter>   to exit
hit the escape key go to command mode from insert mode


find commands in unix
find  where  {permission,type,name,time ...} wat -to -do

search files last 10 days
find  .-size 0  +10  -exec ls -l {} \;>./checkold.txt
cat checkold.txt


grep "literal_string" filename
case senstitive search
grep -i "literal_string" filename
grep "this" abc.*
grep "line.*empty" abc.*
 Sol :abc.txt :line.absoluteempty
exact word search
grep -iw "is" demo_file
Display N lines after match
grep-A <N> "string" FILENAME
grep -A 3 -i "example" demo_txt
Display N lines  before match
grep -B <N> "string"  FILENAME
grep -B 2 "single word" demo_test
Display N Lines around match
grep -C <N> "string" FILENAME
grep -C 2 "Exmaple" demo_txt
Recursively searching
grep -r  "krishna"*
Invert searching
grep -v "go" demo_txt
Counting the no.of matches
grep- c "pattern" filename
grep -r "main" * | wc -l
invert does not have this word main
grep -rv "main" * |wc -l
grep -o -b "pattern" file
o-match only the string
b -show position
show line number while displaying the output
grep -n "go" demo_txt
cat fruits |less
q to exit
cat filename | pg or cat filename | more

cat filename | grep <search string>
cat filename | grep -i a
sort fruits
cat fruits  |grep -v  a | sort -r




No comments:

Post a Comment