Tuesday, November 23, 2010

find command

To find all files modified in the last x days in the given directory(dirName) and its sub-directories:

find dirName -mtime -x -print


To find all files modified more than x days in the given directory(dirName) and its sub-directories:

find dirName -mtime +x -print


For finding only regular files(not the directories) use

find dirName -type f -mtime -x -print


For finding files by name we can use -type f

find dirName -type f -name 'filename'

filename can be regular expression like *.mp3
Case insensitive searches can be achieved by using the -iname flag instead of name

Further we can narrow down the searches by adding more filter like size and modified times
To find .avi files bigger than 700M and modified in the last 15 days:

find dirName -name '*.avi' -a -size +700M -mtime -15


References
http://www.debuntu.org/how-to-find-files-on-your-computer-with-find

Thursday, November 18, 2010

Difference between jsp:include and include directive

<jsp:include>

included jsp page will be compiled separately and the output will replace its position in the main jsp

<%@include% flie="header.jsp">
Contents of the header.jsp gets replaced in the main jsp even before the page compilation

Friday, November 12, 2010

Useful Linux Commands

pushd and popd
For easy directory traversal(good link)

bg, fg and jobs
To run the process in background, foreground and to see what are the current jobs running

file
Give the information about the file format

strings
Outputs all the readable characters in the given file

zgrep
Handy for searching the zip files

pgrep
Handy for searching the process list

pstree

The pstree command is another variation of the PS command. it gives a quick peek at the different programs that are running, and what processes stem from other processes

apropos
apropos is a very powerful command, as it knows every command you can use for a specific item.If you're looking for a certain command to run on, say, directories, but you can't quite remember what it's called, then running apropos dir will yield a list of possible commands.

touch
the touch command is for updating the access / modified date of a file; it’s just a nice side-effect that if the file doesn’t exist, it will create it.

curl
curl -O http://www.domain.com/path/to/download.tar.gz
The -O flag tells curl to write the downloaded content to a file with the same name as the remote file. If you don’t supply this parameter, curl will probably just display the file in the commmand line

patch
patch will be handy with diff

pgrep
pgrep looks through the currently running processes and lists the process IDs which matches the selection criteria.

!!
This will execute the last command you used on the command line.

!...
Execute The Last Command Starting With ...

!ls:p
This will display the command instead of running it.


!$
You can use the last argument from the last command by refering to it as !$

!$:p
Instead of running the last word of the previous command this will print it out.

!*
This bang command will run the previous command without the first word. This one is also only really useful for substitutions as we see in the examples that follow.

!*:p
This will print the previous command without the first word.

$_
You can use the last argument from the last command by refering to it as $_

watch
watch runs a command repeatedly, displaying its output. This allows you to watch the program output change over time. By default, the program is run every 2 seconds. watch is very similar to tail.

Make Parent Directories the Smart Way
mkdir -p /home/adam/make/all/of/these/directories/ will create all directories as needed even if they do not exist.


Ctrl +
CTRL+U deletes whatever is to the left of the cursor and CTRL+K deletes what is to the right.
CTRL+C, which discards the current typed command, and gives you a new line.
CTRL+L will clear the screen.
CTRL+D logout of a terminal session


Resetting your session

Instead of killing and re-starting your terminal session, you can merely type the command reset. This will reset your terminal back to its defaults, clear the screen, and everything will be as it was before.

dmesg

wget
http://www.unixmen.com/linux-tutorials/484-wget-command-line-cheatsheet

lsof
Check for open file descriptors

Other Links
http://www.thegeekstuff.com/2010/11/50-linux-commands/
find command examples
http://blog.urfix.com/25-linux-commands/

Vi
http://www.catswhocode.com/blog/100-vim-commands-every-programmer-should-know
http://www.atoztoa.com/2008/07/effective-use-of-vim-part-1.html

References:-
http://laptoplogic.com/resources/ten-powerful-linux-commands
http://net.tutsplus.com/articles/web-roundups/10-terminal-commands-that-will-boost-your-productivity/
http://blogs.techrepublic.com.com/10things/?p=452
http://www.atoztoa.com/2008/06/linux-commands-i-hardly-knew.html
http://codytaylor.org/2009/09/linux-bang-commands.html
http://www.canoo.com/blog/2010/12/22/beginner-bash-must-know-bash-commands/