Thursday, May 17, 2018

Useful commands

To disable automatic comment insertion in blank lines
-------------------------------------------------------
:set formatoptions-=r formatoptions-=c formatoptions-=o

or insert this in .vimrc
------------------------
au FileType * setlocal fo-=c fo-=r fo-=o

For 4 spaces instead of tab in vi, add this to ~.vimrc:
------------------------------------------------------- 
set expandtab
set tabstop=4
set shiftwidth=4
au FileType * setlocal fo-=c fo-=r fo-=o



" To read fortran code

--------------------------------------------------------
let fortran_free_source=1
let fortran_do_enddo=1
"filetype plugin indent on
syntax on

highlight! link DiffText Todo
 


To create a zero 11G file:
--------------------------
dd if=/dev/zero of=/tmp/dummy_gina count=10 bs=1G

---------------------------------------------------------------------------------
To avoid typing password for ssh login to a mach:
---------------------------------------------------------------------------------
vi ~/.ssh/id_rsa.pub (copy the line here)
ssh
vi ~/.ssh/authorized_keys, add the public key from the machine you are logging
in from.
Make sure permissions on this file is 600


---------------------------------------------------------------------------------
Bash scripts
---------------------------------------------------------------------------------
while true
do
    echo "Hi"
    sleep 1
done

(or)

while sleep 30; do pmap -x ; done

for host in `cat ~/jlt`; do echo $host; done

for i in `cat /tmp/nodes`; do ssh $i dmesg|grep OOM; done
for i in `cat /tmp/nodes`; do ssh $i dmesg|grep segfaul; donefor i in `cat /tmp/nodes`; do ssh $i dmesg|grep segfaul; done


Script to run a list of commands in a file called "cmdlist":

#!/bin/bash

#------------------------------------------------------------------------
# Set the field separator to a newline
IFS="
"

if [ "$#" -ne 1 ]; then
    echo "Usage: $0  "
    exit
fi

# Loop through the file
for line in `cat "$1"`; do
    a=(eval "$line" ">& /dev/null")
    "${a[@]}"
    let status=$?
    if [ $status != 0 ]; then
        echo "${a[1]} ================> FAILED"
    fi
done
 


0 Comments:

Post a Comment

<< Home