cd / find `pwd` -name '.*' -prune -o \( -name *.h -o -name *.cpp \) -print | cscope -bi- export CSCOPE_DB=/cscope.out vim +'set cst'
This is *NOT* about the -i option in grep. I guess everybody already knows that option. This is about the basic rule of life that the simplest things are sometimes the best. ;-) One day when I used "grep -i" for the umpteenth time, I decided to make this alias, and I've used it ever since, probably more often than plain grep. (In fact I also have aliases egrip and fgrip defined accordingly. I also have wrip="grep -wi" but I don't use this one that often.) If you vote this down because it's too trivial and simplistic, that's no problem. I understand that. But still this is really one of my most favourite aliases.
Found this useful for scripts where I needed to work with the machine's IP. If $DEVICE is not specified, this will return all IPs on the machine. If $DEVICE is set to a network adapter, it will return just that adapter's IP.
Loops over array of a system var, splits its values and puts the values into %A, %B, %C, %D, and so on.
Create array before, like
set ARRAY[0]=test1,100
and
set ARRAY[1]=test2,200
Be sure to replace %A, %B, etc. with %%A, %%B, etc. when using this from inside of batch files.
Show Sample Output
Many Mac OS X programs, especially those in Microsoft:Office, create ASCII files with lines terminated by CRs (carriage returns). Most Unix programs expect lines separated by NLs (newlines). This little command makes it trivial to convert them. Show Sample Output
HTP (HTTP Time Protocol) is an alternative way of getting "good enough" synchronized time. htpdate will give you near-second accuracy. It works where NTP/SNTP does not because of firewalls and proxies. Of course, if NTP/SNTP can be used, use that instead. http://www.clevervest.com/twiki/bin/view/HTP htp is not in Ubuntu! Show Sample Output
Simple and fast variant, not using external programs. Another variation:
complete -W "$(while read line; do echo ${line%%[, ]*}; done < ~/.ssh/known_hosts)" ssh
HashKnownHosts must be off, of course.
I know you can use pidof but with this you can know the specific PID with his command arguments (useful if you're running various proccess with same application)
Actually $! is an internal variable containing PID of the last job in background.
More info: http://tldp.org/LDP/abs/html/internalvariables.html#PIDVARREF
Using $! for job control:
possibly_hanging_job & { sleep ${TIMEOUT}; eval 'kill -9 $!' &> /dev/null; }
be careful where you execute this from do a 'sudo ls' beforehand to prime sudo to not ask for your password
lgrep regex [dir]
Shows you all listening tcp/udp ports, and what program has them open(depending on rights)
I can't put the last ^2 with seq, so I reverse it to delete the last +N. So for doing sum(N^2) you have to do sum((N+1)^2). Must be a better way. Show Sample Output
Better -and faster- using bash printf. Show Sample Output
'watch' repeatedly (default every 2 seconds, -n 1 => every second) runs a command (here ':', a shorthand for 'true'), displays the output (here nothing) and the date and time of the last run. I thought it to be obvious but it seemingly is not: to exit use Ctrl-C.
A space-padded version:
perl -m'AptPkg::Cache' -e '$c=AptPkg::Cache->new; for (keys %$c){ push @a, $_ if $c->{$_}->{'CurrentState'} eq 'Installed';} print "$_ " for sort @a;'
Returns yesterday's date in the format yyyyMMdd
Execute this in the root of your music library and this recurses through the directories and normalizes each folder containing mp3s as a batch. This assumes those folders hold an album each. The command "normalize-audio" may go by "normalize" on some systems.
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: