This command will use grep to read the shortcut (which in the above examle is file.url), and filter out all but the only important line, which contains the website URL, and some extra characters that will need to be removes (for example, URL=http://example.com). The cut command is then used to get rid of the URL= at the beginning. The output is then piped into Firefox, which should interpret the it as a web URL to be opened. Of course, you can replace Firefox with any other broswer. Tested in bash and sh.
Google Cloud SDK comes with a package manager `gcloud components` but it needs a bit of `sed` to work. Modify the "^| Not" bit to change the package selection. (The gcloud --format option is currently broken) Show Sample Output
Command returns valid IP addresses. Append the following regex to additionally filter out NAT and reserved IP addresses | grep -Ev "^0|\.0[0-9]|^10\.|^127\.|^169\.|^172\.(1[6-9]|2[0-9]|3[01])|^192.168.|^2(2[4-9]|3[0-9])|^2(4[0-9]|5[0-5])"
For now just returns either "Success" or "Error". My awk-fu isn't strong enough to hackily parse out the error in case there is one, so I kept it simple. Show Sample Output
Show top apps that use internet, sorted by count connections and grouped by TYPE and Protocol 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
Warnings and errors will be suppressed Show Sample Output
us lsof, grep for any pid matching a given name such as "node". Show Sample Output
I like this method because I can make use of pgrep which also has the -f flag that can use regex to match patterns in the full command line string. It will also do ps -fww on all pids returned by pgrep, providing a list of process matching the regex provided. Show Sample Output
You have a clue... 5 Down: You're looking at it (8) You have some letters... C--SS-O-- You use the terminal... Show Sample Output
Grep for: >> non-empty lines : denoted by -v -e '^$' >> that do not start with # (comments) or : denoted by -v -e '^[#\]' >> and does not include : denoted by -v -e '\' (Note that we use -v only once)
Just added a little url encoding with sed - urls with spaces don't work well - this also works against instead of enclosure and adds a sample to show that you can filter against links at a certain domain Show Sample Output
find '.odt' files that contain USAGE: grepodt
Only search source files directly related to current project. Everything under the "node_modules" directly are ignored.
Uses git grep for speed, relies on a valid she-bang, ignores leading whitespace when stripping comments and blank lines Show Sample Output
I wanted a method to display the last run of my script from my log file. I had a pattern I could grep for to find the beginning of each run. This command line greps for that pattern in the log, finds the last occurrence and gives me the line number. Then I use the line number in tail to give me everything from that line number to the end of the log file. I tested this on Linux Mint (variant of Ubuntu) and on RHEL, but I suspect it will run many Linux systems.
I seem to do this compulsively every time I change directories, sometimes even when I don't, even if I know exactly what I need to do. (Don't worry, the sample output is just an exaggeration. :) Show Sample Output
Diverse trunk and branch, when last index is trunk, show trunk repository name when last index minus one is branches, show branch repository name
This will be useful when checking for logs and have to omit specific weblogic or apache server's log information which are redundant and unnecessary. Show Sample Output
grep pdf files easily
-name : base of filename -o : 'or' '*.c' : avoiding "paths must precede expression" error message -type f : only find file type --color: hightlight specific word with color -E : extended regexp 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: