xargs
Is a very useful program to take a list and run commands against that list.
Here is a really straightforward example of using xargs,
- -t will show you what xargs is about to execute before it executes it.
- -n1 limits the arguments passed by the directory to pass one argument, in this case one file name at a time.
Code Block |
---|
Tin-Phams-iMac:PC tinpham$ ls | xargs -t -n1 md5
md5 planetary.doc
MD5 (bash) = ab5970d50d67bcafe5c554387f76534e
md5 Superman.jpg
MD5 (cat) = cdefa50d737dfcf8dc57886ea1a758c4
Tin-Phams-iMac:bin tinpham$
|
Find
Try to memorize this command,
...
lang | html |
---|
...
Table of Contents |
---|
Detailed Articles
Page Tree | ||
---|---|---|
|
Useful One Off Recipes
Disk Management
List directories from largest to smallest at the top level only. On older system h will not work and you must use k.
Code Block | ||
---|---|---|
| ||
du -sh * | sort |
Long Running Processes
Look for long running processes,
Warning |
---|
To write. |
Information
Last
Last searches back through the file /var/log/wtmp (or the file designated by the -f flag) and displays a list of all users logged in (and out) since that file was created.
Lastb
Lastb is the same as last, except that by default it shows a log of the file /var/log/btmp, which contains all the bad login attempts.
Quck String Manipulation
Quick reference of manipulating standout,
Code Block | ||
---|---|---|
| ||
echo "some_file_name.txt" | tr "_" " " # result will be "some file name.txt"
paste oldName.txt newName.txt > runMe.txt # connects line by line to contents of both files together |
Integrity Checking
MD5
Check if a file is corrupt,
Code Block | ||
---|---|---|
| ||
# On Ubuntu
md5sum /path/to/file
# On Solaris
digest -a md5 -v /path/to/file |