Commands by kln0thing (2)

  • The AWK part of the code will "collate" the fields from 2nd to Nth field (this is to handle any svn directories that may have spaces in them - typical when working with code that is interchangeably used with windows environment - for example, documentation teams) - the output is passed to "ls -ld" - the -d option to ls will tell ls to handle directories itself, rather than do ls on the directory. The '-p' option is just for pretty printing directories, links and executables (for added readability). Finally, the entire "constructed" command will be passed onto sh for shell execution. Show Sample Output


    0
    svn status | awk -F" " '{ for (i=2; i<=NF; i++) print "ls -ld \""$i"\""}' | sh
    kln0thing · 2014-07-09 09:41:24 14
  • Original command: cat "log" | grep "text to grep" | awk '{print $1}' | sort -n | uniq -c | sort -rn | head -n 100 This is a waste of multiple cats and greps, esp when awk is being used


    0
    awk '/text to grep/{print $1}' "log" | sort -n | uniq -c | sort -rn | head -n 100
    kln0thing · 2014-07-09 08:48:06 9

What's this?

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.

Share Your Commands


Check These Out

Colorized grep in less
Get your colorized grep output in less(1). This involves two things: forcing grep to output colors even though it's not going to a terminal and telling less to handle those properly.

Replace space in filename
This commands removes space from all the files with specific extension. I've specifed *.jpg as an example.

a function to find the fastest DNS server
http://public-dns.info gives a list of online dns servers. you need to change the country in url (br in this url) with your country code. this command need some time to ping all IP in list.

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Indent a one-liner.
Bash builtin type also indents the function.

Indicates the position of my monitor buttons
I often need to change the brightness of my monitor. The symbols of the sensor buttons are not illuminated and on a black background .... invisible! Now i use osd_cat instead of a torch ;-)

Export a directory to all clients via NFSv4, read/write.
This exports a directory to the world in read/write mode. It is useful for quick, temporary NFS exports. Consider restricting the clients to a subnet or to specific hosts for security reasons (the client can be specified before the colon). On the client: mount -t nfs4 hostname:/ /mountpoint To terminate all of the exports (after unmounting on the client): exportfs -u -a Leave out the fsid=0 option if you don't want NFSv4. This works under recent versions of Linux.

Adding Prefix to File name
Adding course name prefix to lecture pdfs

Hide the name of a process listed in the `ps` output
$ exec -a $NAME $COMMAND $ARGS `your_cmd -erase_all_files` is the real process, but harmless-looking getty appears in the process table. Never actually had a need to do this, but interesting nonetheless... Tested in bash, dash. $ -a $NAME "pass NAME as the zeroth argument to COMMAND", i.e. customise the name of the process (as commonly seen with `ps`)

Install Linux Kernel Headers


Stay in the loop…

Follow the Tweets.

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

Subscribe to the feeds.

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: