xargs: Build and Execute Commands with Arguments from Standard Input

For me when it comes to useful commands xargs ranks along side commands like find, top and df; xargs is a great time saver and incredibly useful. Today I will show a few examples of usage and some of the lesser known features. Basic Usage The xargs command is used to take the output of one command and provide it as arguments to another. Example (xargs): # ls [0-9]-test.xml | xargs chmod -v 644 mode of `1-test.

Cheat Sheet: 21 useful find commands

For todays article I wanted to put together a quick little cheat sheet for some GNU find command examples. Some of these commands will be basic some will be more advanced, but they all will be useful. As a caveat some commands don't work in all Unix environments and this is especially true with older releases. If you find yourself in one of those situations there is a way to make the find command work you will just need to use different methods like the -exec flag.

Find broken Links

At the end of the day this is easier than I expected. Example: [[email protected] play]# find ./ -follow -lname "*" ./somedir4 ./somedir7 ./somedir6 ./somedir5 [[email protected] play]# ls -la total 12 drwxrwxr-x. 3 bcane bcane 4096 Aug 15 18:35 . drwxrwxrwt. 4 root root 4096 Aug 15 18:28 .. drwxr-xr-x. 2 bcane root 4096 Aug 15 18:42 somedir lrwxrwxrwx. 1 root root 7 Aug 15 18:35 somedir1 -> somedir lrwxrwxrwx. 1 root root 7 Aug 15 18:35 somedir2 -> somedir lrwxrwxrwx.

find: Remove files modified more than 31 days ago

This is one of those things that you will run into eventually and once you know how, it is extremely useful. Example: # find ./ -type f -mtime +31 -exec rm {} ; This will find all of the files older than 31 days, If you want to do files and directories you will need two commands. # find ./ -not -type d -mtime +31 -exec rm {} ; # find .