search a file in linux code example

Example 1: linux find any file linux

#find a file and print with path
find . -print | grep -i *.txt

Example 2: linux search for line in file

grep -R "keyword" /directory/

Example 3: how to find a file in linux terminal

find /path/to/folder/ -iname *file_name_portion*

Example 4: search for files in linux terminal

find /path/to/folder/ -iname *file_name_portion*

#Example
find / -iname *test*

#Output

/downloads/test_2.txt
/downloads/test_1.csv
/home/ubuntu/first_test.txt

Example 5: find a file in linux terminal

find /home/username/ -name "*.err"

Example 6: find in file linux

grep -rnw '/path/to/somewhere/' -e 'pattern'