To search for a file there are two types of commands. They are locate and find.
Locate command By using locate command we can search for the file in the entire system (OS).
Syn: $ locate [file name] in whole filing system
Ex: $ locate file1
/home/user1/x/file1
/home/user2/file1
/home/file1
/file1
Find command By using find command we can search only in present working directory. To search in other locations by using –name option we have to specify the path it has to search in.
Syn: $ find [file name] only search in the present working directory
$ find –name [file path] to search for a file in required location
Ex: $ find –name /file1 to search for file1 in root directory.
$ find –name /home/file3 to search for file3 in home directory
wc
To count number of lines, words, chars in a file wc command is used. By using this command multiple files data can also be counted.
Syn: $ wc [file name]
Ex: $ wc file1
3 20 50 file1 here 3 lines 20 words and 50 characters
$ wc file1 file2 file3 file4
3 20 50 file1
2 10 20 file2
5 40 30 file3
6 50 100 file4
Options: -l To display only lines
-w To display only words
-c To display only chars
-lw To display lines and words
-lc To display lines and chars
-wc To display words and chars
od
od – octal dump. It shows the binary format of file.
Options: -b to display ascii values of characters in a file
-bc to display ascii values of characters along with characters.
Ex: $ od -b file1
00060 163 164 158 193
$ od –bc file1
00060 163 164 158 193
a z d c f