Presentation is loading. Please wait.

Presentation is loading. Please wait.

Prepared by, Mr. Satish Pise

Similar presentations


Presentation on theme: "Prepared by, Mr. Satish Pise"— Presentation transcript:

1 Prepared by, Mr. Satish Pise
Experiment No 2 Prepared by, Mr. Satish Pise

2 Grep Command $man grep Syntax - grep [OPTIONS] PATTERN [FILE...]
How do I use grep command to search a file? Create text file as follows: $cat > demofile hello world! cartoons are good especially toon like tom (cat) what the number one song 12221 they love us I too  save file with filename as demofile After saving file, issue following command, $ grep "too" demofile

3 Use grep recursively - # grep -r "192. 168. 1
Use grep recursively - # grep -r " " /etc/ Use grep to search words only - # grep -w "boo" demofile Use grep to search 2 different words - # egrep -w 'word1|word2' demofile Case insensitive search using grep -i # grep -i "the" demo_file

4 Count line when words has been matched - # grep -c 'word' demofile # grep -c "go" demofile # grep -n 'root' /etc/passwd Display N lines around match # grep -C 2 "Example" demofile Invert match using grep -v # grep -v "go" demofile Display only the file names which matches the given pattern # grep -l this demo_*

5 Archiving Files (tar command)
Tar Usage and Options c – create a archive file. x – extract a archive file. v – show the progress of archive file. f – filename of archive file. t – viewing content of archive file. j – filter archive through bzip2. z – filter archive through gzip. r – append or update files or directories to existing archive file. W – Verify a archive file. wildcards – Specify patters in unix tar command.

6 Archiving Files (tar command) - Create first folder cse
#man tar Create tar Archive File # tar -cvf cse.tar /home/cse/ c – Creates a new .tar archive file. v – Verbosely show the .tar file progress. f – File name type of the archive file. Untar tar Archive File # tar -xvf cse.tar List Content of tar Archive File # tar -tvf cse.tar Untar files in specified Directory # tar -xvf cse.tar -C /home/cse

7 Create tar. gz Archive File # tar cvzf cse. tar
Create tar.gz Archive File # tar cvzf cse.tar.gz /home/cse or List Content tar.gz Archive File # tar -tvf cse.tar.gz Uncompress tar.gz Archive File # tar -xvf cse.tar.gz

8 Create tar. bz2 Archive File # tar cvfj cse. tar
Create tar.bz2 Archive File # tar cvfj cse.tar.bz2 /home/cse List Content tar.bz2 Archive File # tar -tvf cse.tar.bz2 Uncompress tar.bz2 Archive File # tar -xvf cse.tar.bz2


Download ppt "Prepared by, Mr. Satish Pise"

Similar presentations


Ads by Google