Useful linux commands
The find
command is only able to filter the directory hierarchy based on a file’s name and meta data. If you need to search based on the content of the file, use a tool like grep. Consider the following example:
find . -type f -exec grep "example" '{}' \; -print
This searches every object in the current directory hierarchy (.
) that is a file (-type f
) and then runs the command grep "example"
for every file that satisfies the conditions. The files that match are printed on the screen (-print
). The curly braces ({}
) are a
placeholder for the find
match results. The {}
are enclosed in single quotes ('
) to avoid handing grep
a malformed file name.
The -exec
command is terminated with a semicolon (;
), which should be escaped (\;
) to avoid interpretation by the shell.
Before the implementation of the -exec
option, this kind of command might have used the xargs
command to generate a similar output:
find . -type f -print | xargs grep "example"
/bin/rm -f -- ^*.php
sudo apt-get remove nodejs
sudo apt-get remove npm
Then go to /etc/apt/sources.list.d
and remove any node list if you have. Then do a
sudo apt-get update