find /path/to/dir -name "*.log" -exec rm {} \; The -exec option runs the specified command (rm in this case) on each file found. The {} placeholder represents the current file. Search by PermissionsThis example shows how to search for files with specific permissions. search_by_...
showing file paths (e.g., "/home/user/code/main.c:function"). Great for codebases. Use-Rto follow symlinks. Runfind /home/user/code -type fto preview files. Add--include=*.cto limit to specific extensions.
You may use the cat command if you just have to add a few lines at the bottom of an existing file. But in order to properly edit a file, you'll need a proper text editor. There is simply no shortage ofterminal-based text editors in Linux.Vi, Vim, Nano, Emacs are just a few of...
As we all knowLinux/Unixconsiderseverything as a file(pipes,sockets,directories,devices,etc). One of the reasons to use thelsofcommand is when a disk cannot be unmounted as it says the files are being used. With the help oflsofcommand, we can easily identify the files which are in use....
[ Free download: Advanced Linux commands cheat sheet. ] ls -lh The -lh flag is the same long list format command as above, however, the file size is displayed in a human-readable format. Notice the difference between the file size outputs in the previous two screens. ls -r This optio...
To find strings and patterns in less, use the /<pattern> or ?<pattern> commands to search forwards or backwards, respectively. Alternatively, you can filter output using the grep utility. For example, the following command recursively lists the files and directories of /usr, but displays only...
The result will show all the places where the file you specified was found. abhishek@linuxhandbook:~$ locate desktop.iso /home/abhishek/desktop.iso The best part is that you don’t need to be in the certain directory to find the file. Remember, locate command doesn’t search the filesyst...
more +n filename Search for a string using more command You can skip to the first instance of a specified string using+/stringafter our command. more +/string filename To find the next instance, you can type/stringinside the more view to search. ...
The "find" command allows you to search for files for which you know the approximate filenames. The simplest form of the command searches for files in the current directory and recursively through its subdirectories that match the supplied search criteria. You can search for files by name, ow...
Most Useful “lsof Command” in Linux Sincethe Linux filesystemconsiders everything in your system as a file, it is mandatory to have better control over your files. The lsof utility lets you do just this and provides much more additional information that is useful in debugging. Network admin...