$ time echo "scale=5000; a(1)*4" | bc -l
Showing posts with label shell. Show all posts
Showing posts with label shell. Show all posts
Tuesday, May 7, 2013
Tuesday, February 12, 2013
List recently modified files under a directory in linux shell
In order to list files that have been modified recently, we could use the find command to retrieve the file information and sort them by modified date:
However, this will miss some folders if the folders are symoblic links. So in this case we could specify find to follow symbolic links.
Fourther more, if you just want to get files modified in last a few days, it's build in in find:
list files that modified n*24 hours ago.
find . -type f -exec stat --format '%Y :%y %n' {} \; | sort -nr | cut -d: -f2- | head
However, this will miss some folders if the folders are symoblic links. So in this case we could specify find to follow symbolic links.
find -L . -type f -exec stat --format '%Y :%y %n' {} \; | sort -nr | cut -d: -f2- | head
Fourther more, if you just want to get files modified in last a few days, it's build in in find:
find . -mtime n
list files that modified n*24 hours ago.
Sunday, November 11, 2012
command sort on last column
As you know, the linux sort command is agile, which can sort on column using -k.
However, if we gonna sort on the last column and each row has different number of columns, we can still achieve that with the help of sed.
However, if we gonna sort on the last column and each row has different number of columns, we can still achieve that with the help of sed.
sed 's/^\(.\+\s\+\)\([0-9]\+ *\)$/\2 \1/'
Tuesday, October 2, 2012
zsh cd tab completion slow
It is quite annoing that zsh seems stuck when completion using tab in a huge directory.
To speed up the zsh completion, append the following lines to ~/.zshrc
# Speed up the zsh completion
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
Sometimes, the directory auto completion works slow under git and svn directories.The solution is to disable it from getting git info and svn info:
For GIT, add following to .zshrc:
For SVN, append this line to .zshrc:
To speed up the zsh completion, append the following lines to ~/.zshrc
# Speed up the zsh completion
zstyle ':completion:*' accept-exact '*(N)'
zstyle ':completion:*' use-cache on
zstyle ':completion:*' cache-path ~/.zsh/cache
Sometimes, the directory auto completion works slow under git and svn directories.The solution is to disable it from getting git info and svn info:
For GIT, add following to .zshrc:
__git_files () {
_wanted files expl 'local files' _files
}
For SVN, append this line to .zshrc:
compdef -d svn
Wednesday, April 11, 2012
Check Port Usage: who is taking my port 8080
Using this command to get the process id:
$ lsof -i :8080
$ lsof -i :8080
Tuesday, February 21, 2012
GNOME Shell Extension development document
I don't know why it is so hard to search for the right development document for GNOME Shell Extension. The Gjs seems wraps all the functionalities to call the shell, but hard to find out how.
After searching and coding. I find out this may be a good one:
http://sander.github.com/tmp/gsdoc/documentation.html
After searching and coding. I find out this may be a good one:
http://sander.github.com/tmp/gsdoc/documentation.html
Wednesday, February 15, 2012
Recursively chmod directories only
find . -type d -exec chmod 755 {} \;
This will recursively search your directory tree (starting at dir ‘dot’) and chmod 755 all directories only.
Similarly, the following will chmod all files only (and ignore the directories):
find . -type f -exec chmod 644 {} \;
Wednesday, February 8, 2012
Shell eliminate warning messages
When I grep the directory, the warning message is really annoying.
$ grep ........ 2 > /dev/null
This will write warnings to /dev/null
$ grep ........ 2 > /dev/null
This will write warnings to /dev/null
Sunday, January 29, 2012
mac lion terminal doesn't source profile
I have encountered the problem that my MacBook Pro ~/.profile doesn't been sourced in the terminal.
The solution is simple:
bash first runs /etc/profile. /etc/profile (on Mac OS X 10.6.7) runs path_helper(8) which is where your default paths get set. After that it runs /etc/bashrc which doesn't do much. Once the default configuration is set, it moves on to the user login scripts.
bash looks in your home directory for .bash_profile, .bash_login, and .profile in that order. bash will run the first of these that it finds and stop looking.
So, if you have a .bash_profile in the home directory, the .profile will be ignored. In this case, just append a line in .bash_profile:
The solution is simple:
bash first runs /etc/profile. /etc/profile (on Mac OS X 10.6.7) runs path_helper(8) which is where your default paths get set. After that it runs /etc/bashrc which doesn't do much. Once the default configuration is set, it moves on to the user login scripts.
bash looks in your home directory for .bash_profile, .bash_login, and .profile in that order. bash will run the first of these that it finds and stop looking.
So, if you have a .bash_profile in the home directory, the .profile will be ignored. In this case, just append a line in .bash_profile:
$cat "source ~/.profile" >> .bash_profile
Saturday, September 10, 2011
Mercurial .hgrc
[ui] username = Steven You <email>[hostfingerprints] bitbucket.org = 81:2b:08:90:dc:d3:71:ee:e0:7c:b4:75:ce:9b:6c:48:94:56:a1:fe [extensions] color =
Thursday, August 18, 2011
Popular Command Lines for Linux
The original article are in three parts:
- Part I: Top Ten One-Liners from CommandLineFu Explained
- Part II: The Next Ten One-Liners from CommandLineFu Explained
- Part III: Another Ten One-Liners from CommandLineFu Explained
- Part IV: Yet Another Ten One-Liners from CommandLineFu Explained
In my post, part_1, part_2, part_3, part_4
I love working in the shell. Mastery of shell lets you get things done in seconds, rather than minutes or hours, if you chose to write a program instead.In this article I’d like to explain the top one-liners from the commandlinefu.com. It’s a user-driven website where people get to choose the best and most useful shell one-liners.
Subscribe to:
Posts (Atom)