Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Linux \ grep search from files and display the file name     - Quagga use authentication on strengthening BGP session security (Linux)

- Android components series Activity (Programming)

- Shell Scripting early experience (Programming)

- Ubuntu users install the video driver Nvidia Driver 334.21 (Linux)

- Java Access Control (Programming)

- Ubuntu install the camera driver (Linux)

- Mount NFS network file system (Linux)

- MySQL partition table Comments (Database)

- React Getting Started Tutorial (Linux)

- MongoDB 3.0 New Features (Database)

- Java in the final qualifier (Programming)

- Exploring the Android Listview display confusion (Programming)

- Android judgment toward camera pictures (Programming)

- Oracle data row split multiple lines (Database)

- Linux disk and File System Concepts (Linux)

- CentOS 6.x systems installation + NIC driver installation (Realtek PCIe GBE Family Controller for Linux) (Linux)

- PL / SQL how to make the program every few seconds to insert a data (Database)

- Java exception handling mechanism (Programming)

- Reset CentOS / RHEL root account password 7 (Linux)

- Ubuntu 14.04 install PostgreSQL 9.2 (Database)

 
         
  grep search from files and display the file name
     
  Add Date : 2018-11-21      
         
         
         
  How do I search from several files (grep), and displays only the file name to match the file?

When you search from more than one file, it displays the default file name:

grep "word" filename
grep root / etc / *
Sample output:

/etc/bash.bashrc:See"man sudo_root "for details.
/ Etc / crontab: 17 **** root cd / && run-parts --report /etc/cron.hourly
/ Etc / crontab: 256 *** root test-x / usr / sbin / anacron || (cd / && run-parts --report /etc/cron.daily)
/ Etc / crontab: 476 ** 7 root test-x / usr / sbin / anacron || (cd / && run-parts --report /etc/cron.weekly)
/ Etc / crontab: 5261 ** root test-x / usr / sbin / anacron || (cd / && run-parts --report /etc/cron.monthly)
/ Etc / group: root: x: 0:
grep: / etc / gshadow: Permission denied
/etc/logrotate.conf: create 0664 root utmp
/etc/logrotate.conf: create 0660 root utmp
Each line starting with the first part of the file name (eg: / etc / crontab, / etc / group). Use the -l option to display only the file name:

grep-l "string" filename
grep-l root / etc / *
Sample output:

/ Etc / aliases
/etc/arpwatch.conf
grep: /etc/at.deny: Permission denied
/etc/bash.bashrc
/ Etc / bash_completion
/etc/ca-certificates.conf
/ Etc / crontab
/ Etc / group
You can also reverse the output; using the -L option to output the name of a file that does not match:

grep-L "word" filename
grep-L root / etc / *
Sample output:

/ Etc / apm
/ Etc / apparmor
/etc/apparmor.d
/ Etc / apport
/ Etc / apt
/ Etc / avahi
/etc/bash_completion.d
/etc/bindresvport.blacklist
/etc/blkid.conf
/ Etc / bluetooth
/etc/bogofilter.cf
/ Etc / bonobo-activation
/etc/brlapi.key
     
         
         
         
  More:      
 
- CentOS7 build GlusterFS (Linux)
- Sudo and Root Account in Ubuntu related (Linux)
- Linux Getting Started tutorial: How to backup Linux systems (Linux)
- Ubuntu Froxlor Server Administration panel installation (Server)
- The Java Properties class action (Programming)
- Linux Network Programming --epoll model Detailed principles and examples (Programming)
- Getting the Linux shell variable test (Programming)
- Talk about the Linux folder permissions issue again (Linux)
- Linux Firewall Builder shorewall (Linux)
- PostgreSQL log classification and management (Database)
- Let CentOS perform PPPoE dial-up, ADSL can be used in a network environment! (Linux)
- Java concurrent programming using the synchronized keyword ReentrantLock alternative primitive (Programming)
- Verify the character set on MyCAT (Database)
- Three binary tree traversal (recursive, non-recursive traversal and Morris) (Programming)
- Linux Regular expressions grep and egrep (Linux)
- Oracle 11g creates virtual private directory RMAN-06004 ORA-00942 error handling (Database)
- The YUM package management under Linux (Linux)
- Job achieve automation in Ubuntu 14.04 - Using Cron (Linux)
- Hadoop vs spark (Server)
- Copy and paste in Linux terminal and Vim (Linux)
     
           
     
  CopyRight 2002-2020 newfreesoft.com, All Rights Reserved.