using_grep
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
using_grep [2016/09/06 19:34] – walkeradmin | using_grep [2023/03/09 22:35] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Using GREP ====== | ====== Using GREP ====== | ||
+ | <color darkorange> | ||
+ | \\ | ||
\\ | \\ | ||
\\ | \\ | ||
Line 80: | Line 82: | ||
grep -v bar / | grep -v bar / | ||
\\ | \\ | ||
+ | \\ | ||
+ | ===== UNIX / Linux pipes and grep command ===== | ||
+ | grep command often used with shell pipes. In this example, <color red>show the name of the hard disk devices:</ | ||
+ | \\ | ||
+ | dmesg | egrep ' | ||
+ | | ||
+ | [ 2.535530] sdhci: Secure Digital Host Controller Interface driver | ||
+ | [ 2.539697] sdhci: Copyright(c) Pierre Ossman | ||
+ | [ 2.542163] sdhost: log_buf @ bac46000 (fac46000) | ||
+ | [ 2.619698] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1) | ||
+ | [ 2.691142] sdhci-pltfm: | ||
+ | [ 6.716496] bcm2835-wdt 3f100000.watchdog: | ||
+ | [ 7.186573] brcmfmac: brcmf_sdio_drivestrengthinit: | ||
+ | \\ | ||
+ | Display cpu model name: | ||
+ | \\ | ||
+ | cat / | ||
+ | | ||
+ | model name : ARMv7 Processor rev 4 (v7l) | ||
+ | model name : ARMv7 Processor rev 4 (v7l) | ||
+ | model name : ARMv7 Processor rev 4 (v7l) | ||
+ | model name : ARMv7 Processor rev 4 (v7l) | ||
+ | \\ | ||
+ | However, above command can be also used as follows without shell pipe: | ||
+ | \\ | ||
+ | grep -i ' | ||
+ | \\ | ||
+ | \\ | ||
+ | ===== How do I list just the names of matching files? ===== | ||
+ | Use the -l option to list file name whose contents mention main(): | ||
+ | \\ | ||
+ | grep -l ' | ||
+ | \\ | ||
+ | \\ | ||
+ | ===== Force grep to display output in colours ===== | ||
+ | Finally, you can force grep to display output in colors, enter: | ||
+ | \\ | ||
+ | <color red> | ||
+ | \\ | ||
+ | grep --color pi / | ||
\\ | \\ | ||
+ | |||
+ | | ||
| | ||
using_grep.1473186888.txt.gz · Last modified: 2023/03/09 22:35 (external edit)