Posts

Tabbed vim

I always felt like we should have tabs in vim so that I wont have to split screen using "vim -O option / ":vs". I just found that we can use tabs.  vim -p < file1 > < file2 > You can see that you can open multiple files and go to next file without saving (something you cannot do in multiple buffer). Youcan switch between files using tabn/tabp, but I do it as follows and use F5/6.  :map <f5> :tabp <cr>  :map <f6> :tabn <cr>

Shell commands in VIM

If we need to execute a shell command on currently opened file in VIM, we can do following   :%! sed G          Double space the entire file.   :1,5! sed G        Double space the lines from 1-5.

Downloading flash videos in ubuntu

Here is a modified version of a online script I found to download videos. Online script download everything which is a clutter because it has many flash ads too. $ cat ~/Dropbox/new_installation/scripts/flash_vid.sh #!/bin/bash num=1; for FILE in $(lsof -n | grep "Flash.*deleted" | awk '{printf "/proc/" $2 "/fd/"; sub(/[a-z]+/,"",$4); print $4}'); do cp $FILE $HOME/Desktop/$num.flv size=$( stat -c %s $HOME/Desktop/$num.flv); if [ $size -gt 5000000 ]; then num=$[$num + 1]; else rm $HOME/Desktop/$num.flv; fi done

CVS important commands

cvs add < filename > cvs commit -m "my comment < filename > cvs update < filename > cvs -j < what version you want cvs to think it has > -j<what version you want cvs to go to > < filename >

linux commandline mail from shell as attachement

There are few ways to do this. Here are some : (cat mailtext; uuencode surfing.jpeg surfing.jpeg) | mail sylvia@home.com uuencode $ATTFILE $ATTFILE | mail -s "$SUBJECT" $MAILTO echo "hi" | mutt -a $ATTFILE -s "$SUBJECT" $MAILTO

mysqldump

Transferring data between two tables/two databases can be achieved by insert into table1 select * deom database2.table2; But they are not on the same host you can use following : $ mysqldump -h host_name -u user_name -p database table_name "--where= date = 20111121" > temp We can use "-t" option which will exclude table creation definition from the output.

Finding latest modified file/directory

Another useful command $ find . -exec stat \{} --printf="%y %n\n" \; | sort -n -r | head -1 $ for i in `ls`; do echo -n $i" "; find $i -exec stat \{} --printf="%y %n\n" \; | sort -n -r | head -1;done