17 Şubat 2011 Perşembe

"grep" Tool.

It is a new tool that I discover and I guess it is also really beneficial for you (The CS'ers). It is to search a String pattern in all kind of documents and the tool gives you the all matching documents and the line numbers of matchings of these documents.
Here is the basic structure of the usage;

grep [options] pattern filieTypes

[options] side to activate some extra functionalities. You can see the documentation in terminal by typing "grep --help"

Here also an example which search "sys_getpid" string in the all file types in directories with subdirectories.




erogol@ubuntu:~/Desktop/linux-2.6.37$ grep -Hrni sys_getPid *
arch/microblaze/kernel/syscall_table.S:27: .long sys_getpid /* 20 */
arch/mips/kernel/scall64-o32.S:227: PTR sys_getpid /* 4020 */
arch/mips/kernel/scall64-64.S:168: PTR sys_getpid
arch/mips/kernel/scall64-n32.S:163: PTR sys_getpid
arch/mips/kernel/scall32-o32.S:259: sys sys_getpid 0 /* 4020 */
arch/avr32/kernel/syscall_table.S:36: .long sys_getpid /* 20 */
arch/xtensa/include/asm/unistd.h:281:__SYSCALL(120, sys_getpid, 0)
arch/xtensa/platforms/iss/include/platform/simcall.h:39:#define SYS_getpid 20
arch/s390/kernel/syscalls.S:31:SYSCALL(sys_getpid,sys_getpid,sys_getpid) /* 20 */
arch/sparc/kernel/systbls_64.S:25:/*20*/ .word sys_getpid, sys_capget, sys_capset, sys_setuid16, sys_getuid16
arch/sparc/kernel/systbls_64.S:101:/*20*/ .word sys_getpid, sys_capget, sys_capset, sys_setuid, sys_getuid
arch/sparc/kernel/systbls_32.S:23:/*20*/ .long sys_getpid, sys_capget, sys_capset, sys_setuid16, sys_getuid16
arch/frv/kernel/entry.S:1212: .long sys_getpid /* 20 */
arch/x86/include/asm/unistd_64.h:98:__SYSCALL(__NR_getpid, sys_getpid)
Binary file arch/x86/kernel/syscall_64.o matches
arch/x86/kernel/syscall_table_32.S:22: .long sys_getpid /* 20 */
Binary file arch/x86/kernel/built-in.o matches
Binary file arch/x86/built-in.o matches
arch/x86/ia32/ia32entry.S:533: .quad sys_getpid /* 20 */
Binary file arch/x86/ia32/built-in.o matches
Binary file arch/x86/ia32/ia32entry.o matches
arch/m68k/kernel/entry.S:451: .long sys_getpid /* 20 */
arch/parisc/hpux/entry_hpux.S:51: ENTRY_NAME(sys_getpid) /* 20 */
arch/sh/kernel/syscalls_32.S:39: .long sys_getpid /* 20 */
arch/sh/kernel/syscalls_64.S:43: .long sys_getpid /* 20 */
arch/cris/arch-v10/kernel/entry.S:625: .long sys_getpid /* 20 */
arch/cris/arch-v32/kernel/entry.S:568: .long sys_getpid /* 20 */
arch/h8300/kernel/syscalls.S:37: .long SYMBOL_NAME(sys_getpid) /* 20 */
arch/ia64/kernel/fsys.S:61:ENTRY(fsys_getpid)
arch/ia64/kernel/fsys.S:92:END(fsys_getpid)
arch/ia64/kernel/fsys.S:782: data8 fsys_getpid // getpid
arch/ia64/kernel/entry.S:1489: data8 sys_getpid
arch/m32r/kernel/syscall_table.S:22: .long sys_getpid /* 20 */
arch/mn10300/kernel/entry.S:460: .long sys_getpid /* 20 */
arch/blackfin/mach-common/entry.S:1386: .long _sys_getpid /* 20 */
arch/arm/kernel/calls.S:32:/* 20 */ CALL(sys_getpid)
arch/m68knommu/kernel/syscalltable.S:41: .long sys_getpid /* 20 */
...

1 yorum: