For a given filesystem return the LUN ID. Command assumes 1:1 relationship between fs:lv:hdisk:lun which may not be the case in all environments. Show Sample Output
Works even with spaces in filenames. As an alias in .gitconfig: [alias] editchanged = "!git status --porcelain | sed -ne 's/^ M //p' | tr '\\n' '\\0' | tr -d '\"' | xargs -0 vim"
When you run a lot of containers the built in docker ps output becomes unreadable. This command formats the output to be easier on the eyes. Requires q (https://github.com/harelba/q) text as data. Show Sample Output
Filter entries in OpenSuse /var/log/messages like: timestamp servername kernel: [83242.108090] btrfs: checksum error at logical 1592344576 on dev /dev/sda5, sector 5223584, root 5, inode 2652, offset 282624, length 4096, links 1 (path: log/warn) Show Sample Output
This command allows to follow up a trace on SDP (CS5.2), at the same time as the trace records are stored in the file with "raw" format.
Trace files in native format are useful to filter the records before to translation from '|' to '\n'.
Example:
grep -v OP_GET <raw-records>.trace | tr '|' '\n'
Show Sample Output
Thx Mass1 for the sharing
This approach deals with special characters such as apostrophe and whitespace in the file/directory names. tr '\n' '\0' converts the newline delimiting into NUL delimitering which xargs -0 expects. It works on systems which do not yet support xargs -d or sort -h, and includes files in addition to directories. Show Sample Output
In the field, I needed to script a process to scan a specific vendor devices in the network. With the help of nmap, I got all the devices of that particular vendor, and started a scripted netcat session to download configuration files from a tftp server. This is the nmap loop (part of the script). You can however, add another pipe with grep to filter the vendor/manufacturer devices only. If want to check the whole script, check in http://pastebin.com/ju7h4Xf4 Show Sample Output
tr ' ' '\n' isn't needed, it's just there to make the output prettier. Show Sample Output
Removes directories which are less than 1028KB total. This works for systems where blank directories are 4KB. If a directory contains 1 MB (1024KB) or less, it will remove the directory using a path relative to the directory where the command was initially executed (safer than some other options I found).
Adjust the 1028 value for your needs.
It would be helpful to test the results before proceeding with the removal. Simply run all but the last two commands to see a list of what will be removed:
du | awk '{if($1<1028)print;}' | cut -d $'\t' -f 2-
If you're unsure what size a blank folder is, test it like this:
mkdir test; du test; rmdir test
A great command to assign to an alias, allowing you to git diff the last two commits in git.
Useful when you need to generate password or random hash string. If you need longer string adjust parameter for "head -c 20" Show Sample Output
I had trouble with accent I could do a simple mv by hand but it is not efficient. I found this online http://www.unix.com/shell-programming-and-scripting/158635-remove-spanish-accent-file-name.html but I could not specify the accented letter direcly because it is not in the same encoding as my cli so I changed the char for their octal value. to add accent I use this table http://linux.about.com/library/cmd/blcmdl7_iso_8859-1.htm and add the values to the tr part. the other "duplicates" where not working for me. comment to help me better this script. :) Show Sample Output
Inspired by Tatsh's comment.
I always forget this one and find all kinds of complex solutions on google. Also works great while piping data. ex. 'cat data | process-data | tr -d "\"" > processed-data-without-quotes'
Time protocol serves up seconds since 1900 in a 32 bit binary number. Show Sample Output
this one includes special characters. note some some chars may be disallowed on windows systems. *nix will allow pretty much any character in a password except a carriage return. you do not want non printing characters in your password, so this is limited to the printable chars displayed on a keyboard , less space and return. edited to fix minor typo Show Sample Output
Returns a list, with attributes (think `ls -l`), in reverse chronological order. N is a single numeric parameter. Robust against unfriendly filenames and directory structures. Show Sample Output
debian kernel 4.4.6 Show Sample Output
This server can be access by a browser or other remote terminal with ncat. I have to use de test && break to allow ctrl-c to close. Show Sample Output
Check that all websites on the current server are working as expected. This is a quick easy way to do that. Show Sample Output
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: